[英]PHP Trying to get property of non-object
I'm running an APNS PHP script and it's working fine but one file throws PHP errors and I want to know how I should fix it. 我正在运行一个APNS PHP脚本,它工作正常,但是一个文件引发PHP错误,我想知道应该如何解决。
The following errors pop up: 弹出以下错误:
/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
Line 46: 第46行:
$apns = new apns($server->ServerUrl, $certificatePath, $certificate->Passphrase);
Line 66: 66行:
$this->stream = stream_socket_client($this->server, $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
Line 69: 第69行:
throw new Exception("<br/>Failed to connect $err $errstrn");
PHP file: https://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/processFeedback.php 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 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 APNS.php: https : //github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master/classes/Apns.php
I'm not a PHP expert so what am I missing? 我不是PHP专家,所以我想念什么?
Just spotted this in the stack trace: 刚刚在堆栈跟踪中发现了这一点:
#1 /usr/share/nginx/www/processFeedback.php(46): Apns->__construct(NULL, 'certificates/ck...', 'passwd') .
This clearly shows that $server is NULL. 这清楚地表明$ server为NULL。 What do you expect the ServerUrl to be? 您期望ServerUrl是什么? Maybe you could just enter that as a string in the line in question, like so: 也许您可以将其作为字符串输入相关行,如下所示:
$apns = new apns('myServerUrl', $certificatePath, $certificate->Passphrase)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.