0

我正在运行一个 APNS PHP 脚本,它工作正常,但是一个文件引发 PHP 错误,我想知道我应该如何修复它。

弹出以下错误:

/usr/bin/php -f /usr/share/nginx/www/processFeedback.php

<br/>Started processing FeedbackPHP Notice:  Trying to get property of non-object in /usr/share/nginx/www/processFeedback.php on line 46
PHP Warning:  stream_socket_client(): unable to connect to  (Failed to parse address "") in /usr/share/nginx/www/classes/Apns.php on line 66
PHP Notice:  Undefined variable: errstrn in /usr/share/nginx/www/classes/Apns.php on line 69
PHP Fatal error:  Uncaught exception 'Exception' with message '<br/>Failed to connect 0 ' in /usr/share/nginx/www/classes/Apns.php:69
Stack trace:
#0 /usr/share/nginx/www/classes/Apns.php(49): Apns->connect()
#1 /usr/share/nginx/www/processFeedback.php(46): Apns->__construct(NULL, 'certificates/ck...', 'passwd')
#2 {main}
  thrown in /usr/share/nginx/www/classes/Apns.php on line 69

第 46 行:

$apns = new apns($server->ServerUrl, $certificatePath, $certificate->Passphrase);

第 66 行:

$this->stream = stream_socket_client($this->server, $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);

第 69 行:

throw new Exception("<br/>Failed to connect $err $errstrn");

PHP文件:https ://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/processFeedback.php

DataService.php:https ://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/classes/DataService.php

APNS.php:https ://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/classes/Apns.php

我不是 PHP 专家,所以我错过了什么?

4

1 回答 1

0

刚刚在堆栈跟踪中发现了这个:

#1 /usr/share/nginx/www/processFeedback.php(46): Apns->__construct(NULL, 'certificates/ck...', 'passwd') .

这清楚地表明 $server 为 NULL。您期望 ServerUrl 是什么?也许您可以在相关行中将其作为字符串输入,如下所示:

$apns = new apns('myServerUrl', $certificatePath, $certificate->Passphrase)
于 2013-01-30T16:04:19.007 回答