Pusher in php – 不发送事件[Unknown auth_key]

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Pusher in php – 不发送事件[Unknown auth_key]脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用以下代码

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 );

我的答案是:

Pusher: ->trigger received string channel "test_channel". Converting to array. Pusher: create_curl( http://api.pusherapp.COM:80/apps/*/events?auth_key=*&amp;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 ---

我究竟做错了什么?

我想要的是从服务器发送通知.

解决方法

我怀疑你的群集可能是错的.

dashboard.pusher.com上创建Pusher应用程序时,系统会要求您选择一个群集:

Pusher in php – 不发送事件[Unknown auth_key]

pusher-http-php-master认连接到mt1(us-east-1).如果你选择了另一个集群 – 比如eu(eu-west-1) – 你需要明确

$pusher = new Pusher(
  $app_key,$app_id,array( 'cluster' => 'eu' ) 
);

如果这不起作用,我会双倍检查您的$app_secret.

脚本宝典总结

以上是脚本宝典为你收集整理的Pusher in php – 不发送事件[Unknown auth_key]全部内容,希望文章能够帮你解决Pusher in php – 不发送事件[Unknown auth_key]所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。