I am using the following code:
require('pusher-http-php-master/lib/Pusher.php');
error_reporting(E_ALL);
$app_id = '*';
$app_key = '*';
$app_secret = '*';
class MyLogger {
public function log( $msg ) {
print_r( $msg . "<br />" );
}
}
$pusher = new Pusher($app_key, $app_secret, $app_id);
$logger = new MyLogger();
$pusher->set_logger( $logger );
$data['message'] = 'hello world';
$result = $pusher->trigger('test_channel', 'my_event', array( 'hello' => 'world' ));
$logger->log( "---- My Result ---" );
$logger->log( $result );
And the answer I have is:
Pusher: ->trigger received string channel "test_channel". Converting to array. Pusher: create_curl( http://api.pusherapp.com:80/apps/*/events?auth_key=*&auth_signature=*&auth_timestamp=*&auth_version=1.0&body_md5=*) Pusher: trigger POST: {"name":"my_event","data":"{\"hello\":\"world\"}","channels":["test_channel"]} Pusher: exec_curl response: Array ( [body] => Unknown auth_key [status] => 400 ) ---- My Result ---
What am I doing wrong?
What I want is to send notifications from the server.
I suspect your cluster
might be wrong.
When you create a Pusher application on dashboard.pusher.com, you're asked to choose a cluster
:
pusher-http-php-master
connects to mt1 (us-east-1)
by default. If you chose another cluster - like eu (eu-west-1)
- you'll need to be explicit:
$pusher = new Pusher(
$app_key,
$app_secret,
$app_id,
array( 'cluster' => 'eu' )
);
If that doesn't work, I would double triple check your $app_secret
.
I had the same problem when i was using Pusher with Lumen. For me what worked was i removed the package from composer and reinstalled the package.
first
composer remove pusher/pusher-php-server
then
composer require pusher/pusher-php-server
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With