Recently in the bounty hunter to make a new website to use pusher to make a home noise, I in the local test is OK after deploying it to Linux, but opened to find it impossible to implement the message issued, open pusher console View information is the display channel connected, But the event that sent the message is not executed. I open local (local and deployed using the same pusher app), and local hair can be displayed on the top of the deployment. I haven't found the problem for a long day.
The entire project is structured as follows:
main.js
File contents:
(function($){ var pusher = new Pusher('18f9924cb7ee44a01ec0'), channel = pusher.subscribe('imgondar'); Pusher.log = function( msg ) { if( console && console.log ) { console.log( msg ); } }; channel.bind('send_message', function (data) { Snarl.addNotification({ title: data.name, text: data.msg, timeout: 5000 }); }); $('form').submit(function(){ var say = $('#message').val(); if ( say ) { $.post('post.php', $(this).serialize()); $('#message').val('').focus(); } return false; });})(jQuery);
post.php
file contents:
!--? phprequire './lib/pusher.php '; $app _id = ' 111087 '; $app _key = ' 18f9924cb7ee44a01ec0 '; $app _secret = ' 09c7dd1a71a92c90ce2d '; $pusher = new Pusher ($app _key, $app _secret, $app _id); $data = Array (' name ' =--> htmlentities (get Name (). ': '), ' msg ' = = Htmlentities (strip_tags ($_request[' message '))); $pusher->trigger (' Imgondar ', ' Send_ Message ', $data); function GetName () {$name _array = Array (0 = "Little Dragon Girl", 1 = "Yang", 2 = "Jin Yong", 3 = "Guo Jing", 4 = " Huang Rong ", 5 =" Ouyang Fung ", 6 =" Duan Yu ", 7 =" Language Yan ", 8 =" Virtual Bamboo ", 9 =" Animal Husbandry Dust "," Java ", one by one =" JavaScript "," Pyth " On "," + + "C + +", "HTML", "what Ghost ~ ~", "I do not think out ^ ^", "Rick", "and" "is to spit groove," " A "," and "" passers-by "," and "" Walk "," the protagonist "," I am a woman "," I am only a Slave, "" and "please call me to tolerate Mammy," and "I will drop Dragon 18 Palm", 27 =& Gt "Small white", "!-_-" "Without Words", "Qiao", "the" "" Bad people "," and "; $index = rand (0, COUNT ($name _array)-1); return $name _array[$index];}
After the local http://127.0.0.1/imgondarv8_test/access, click Send, see the following effect in the browser:
Because I main.js
let it output the log in the code, open the browser's console to see:
Open the Pusher console:
Now that's the problem, I've deployed the code through SVN to a Linux server, accessed by the following domain name:
http://testgondar.helloarron.com/
After clicking Send no effect, pusher console and browser console information as follows:
The message was not sent successfully, although it was connected.
But I use the local http://127.0.0.1/imgondarv8_test/message can be in the deployment of what is received (after all using the same pusher application), in the browser console display received information:
Testing for a half day is post.php inside the $pusher->trigger('imgondar', 'send_message', $data);
Linux is not executed below.
View the Pusher.php
functions of the file trigger
:
Public function trigger ($channel, $event, $payload, $socket _id = null, $debug = False, $already _encoded = False) {$c h = curl_init (); if ($ch = = = False) {die (' Could not initialise curl! '); } # ADD Channel to URL: $s _url = $this->settings[' url '). '/channels/'. $channel. '/events '; # Build the request $signature = "post\n". $s _url. "\ n"; $payload _encoded = $already _encoded? $payload: Json_encode ($payload); $query = "auth_key=". $this->settings[' Auth_key '). "&auth_timestamp=". Time (). "&auth_version=1.0&body_md5=". MD5 ($payload _encoded). "&name=". $event; # Socket ID set? if ($socket _id!== null) {$query. = "&socket_id=". $socket _id; # Create the signed signature ... $auth _signature = Hash_hmac (' sha256 ', $signature. $query, $this->settings[' s Ecret '], false); $signed _query = $query. "&auth_signature=". $auth _signature; $full _url = $this->settings[' server '). ':' . $this->settings[' Port ']. $s _url. '?' . $signed _query; # Set CURL opts and execute request curl_setopt ($ch, Curlopt_url, $full _url); curl_setopt ($ch, Curlopt_httpheader, Array ("Content-type:application/json")); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_postfields, $payload _encoded); curl_setopt ($ch, curlopt_timeout, $this->settings[' TIMEOUT '); $response = curl_exec ($ch); Curl_close ($ch); if ($response = = "202 accepted\n" && $debug = = False) {return true; } elseif ($debug = = True | | $this->settings[' DEBUG '] = = True) {return $response; } else {return false; }}
I think it may be Linux under the PHP environment does not open the curl
module, so I wrote a simple crawl Baidu home page example, found on the server curl
is open. Can not find other reasons, but also asked the great God to give a weapon. Thank you ^ ^
Reply content:
Recently in the bounty hunter to make a new website to use pusher to make a home noise, I in the local test is OK after deploying it to Linux, but opened to find it impossible to implement the message issued, open pusher console View information is the display channel connected, But the event that sent the message is not executed. I open local (local and deployed using the same pusher app), and local hair can be displayed on the top of the deployment. I haven't found the problem for a long day.
The entire project is structured as follows:
main.js
File contents:
(function($){ var pusher = new Pusher('18f9924cb7ee44a01ec0'), channel = pusher.subscribe('imgondar'); Pusher.log = function( msg ) { if( console && console.log ) { console.log( msg ); } }; channel.bind('send_message', function (data) { Snarl.addNotification({ title: data.name, text: data.msg, timeout: 5000 }); }); $('form').submit(function(){ var say = $('#message').val(); if ( say ) { $.post('post.php', $(this).serialize()); $('#message').val('').focus(); } return false; });})(jQuery);
post.php
File contents:
!--? phprequire './lib/pusher.php '; $app _id = ' 111087 '; $app _key = ' 18f9924cb7ee44a01ec0 '; $app _secret = ' 09c7dd1a71a92c90ce2d '; $pusher = new Pusher ($app _key, $app _secret, $app _id); $data = Array (' name ' =--> htmlentities (get Name (). ': '), ' msg ' = = Htmlentities (strip_tags ($_request[' message '))); $pusher->trigger (' Imgondar ', ' Send_ Message ', $data); function GetName () {$name _array = Array (0 = "Little Dragon Girl", 1 = "Yang", 2 = "Jin Yong", 3 = "Guo Jing", 4 = " Huang Rong ", 5 =" Ouyang Fung ", 6 =" Duan Yu ", 7 =" Language Yan ", 8 =" Virtual Bamboo ", 9 =" Animal Husbandry Dust "," Java ", one by one =" JavaScript "," Pyth " On "," + + "C + +", "HTML", "what Ghost ~ ~", "I do not think out ^ ^", "Rick", "and" "is to spit groove," " A "," and "" passers-by "," and "" Walk "," the protagonist "," I am a woman "," I am only a Slave, "" and "please call me to tolerate Mammy," and "I will drop Dragon 18 Palm", 27 =& Gt "Small white", "!-_-" "Without Words", "Qiao", "the" "" Bad people "," and "; $index = rand (0, COUNT ($name _array)-1); return $name _array[$index];}
After the local http://127.0.0.1/imgondarv8_test/access, click Send, see the following effect in the browser:
Because I main.js
let it output the log in the code, open the browser's console to see:
Open the Pusher console:
Now that's the problem, I've deployed the code through SVN to a Linux server, accessed by the following domain name:
http://testgondar.helloarron.com/
After clicking Send no effect, pusher console and browser console information as follows:
The message was not sent successfully, although it was connected.
But I use the local http://127.0.0.1/imgondarv8_test/message can be in the deployment of what is received (after all using the same pusher application), in the browser console display received information:
Testing for a half day is post.php inside the $pusher->trigger('imgondar', 'send_message', $data);
Linux is not executed below.
View the Pusher.php
functions of the file trigger
:
Public function trigger ($channel, $event, $payload, $socket _id = null, $debug = False, $already _encoded = False) {$c h = curl_init (); if ($ch = = = False) {die (' Could not initialise curl! '); } # ADD Channel to URL: $s _url = $this->settings[' url '). '/channels/'. $channel. '/events '; # Build the request $signature = "post\n". $s _url. "\ n"; $payload _encoded = $already _encoded? $payload: Json_encode ($payload); $query = "auth_key=". $this->settings[' Auth_key '). "&auth_timestamp=". Time (). "&auth_version=1.0&body_md5=". MD5 ($payload _encoded). "&name=". $event; # Socket ID set? if ($socket _id!== null) {$query. = "&socket_id=". $socket _id; # Create the signed signature ... $auth _signature = Hash_hmac (' sha256 ', $signature. $query, $this->settings[' s Ecret '], false); $signed _query = $query. "&auth_signature=". $auth _signature; $full _url = $this->settings[' server '). ':' . $this->settings[' Port ']. $s _url. '?' . $signed _query; # Set CURL opts and execute request curl_setopt ($ch, Curlopt_url, $full _url); curl_setopt ($ch, Curlopt_httpheader, Array ("Content-type:application/json")); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_postfields, $payload _encoded); curl_setopt ($ch, curlopt_timeout, $this->settings[' TIMEOUT '); $response = curl_exec ($ch); Curl_close ($ch); if ($response = = "202 accepted\n" && $debug = = False) {return true; } elseif ($debug = = True | | $this->settings[' DEBUG '] = = True) {return $response; } else {return false; }}
I think it may be Linux under the PHP environment does not open the curl
module, so I wrote a simple crawl Baidu home page example, found on the server curl
is open. Can not find other reasons, but also asked the great God to give a weapon. Thank you ^ ^
The great God, help me out.
See if your PHP code has permission to execute!
Curl problem actually you open puser.php Debug mode will find the returned status=0
As long as the pusher.php in the trigger method curl the piece plus
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false);
That's it.