Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么在包含正确的名称空间后仍会出现致命错误?_Php_Exception_Exception Handling_Fatal Error_Pushwoosh - Fatal编程技术网

Php 为什么在包含正确的名称空间后仍会出现致命错误?

Php 为什么在包含正确的名称空间后仍会出现致命错误?,php,exception,exception-handling,fatal-error,pushwoosh,Php,Exception,Exception Handling,Fatal Error,Pushwoosh,以下是我编写的使用php pushwoosh库发送推送通知的程序: <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); use Gomoob\Pushwoosh\Client\Pushwoosh; use Gomoob\Pushwoosh\Model\Request\CreateMessageRequest; use Gomoob\Pushwoosh\Mo

以下是我编写的使用php pushwoosh库发送推送通知的程序:

<?php
ini_set('display_startup_errors',1);
ini_set('display_errors',1);
error_reporting(-1);

use Gomoob\Pushwoosh\Client\Pushwoosh;
use Gomoob\Pushwoosh\Model\Request\CreateMessageRequest;
use Gomoob\Pushwoosh\Model\Notification\Notification;
use Gomoob\Pushwoosh\Exception;

require __DIR__.'/vendor/autoload.php';

/*require('../config.php');
require('../common.php');*/

$data = json_decode(file_get_contents('php://input'), true);

$auth_token = $data['auth_token'];
$app_code   = $data['app_code'];
$page_no    = $data['page_no'];
$page_total = $data['page_total'];

define('PW_AUTH', $auth_token);
define('PW_APPLICATION', $app_code);

// Create a Pushwoosh client
$pushwoosh = Pushwoosh::create()
    ->setApplication(PW_AUTH)
    ->setAuth(PW_APPLICATION);

if(!empty($page_no) && !empty($page_total)) {

  if (!Phpfox::isUser()) {
    $flag = false;
    $response["error"] = "error";
    $response["message"] = "Please login";
    echoRespnse(401, $response);

  } else {    

    $notificaions = Phpfox::getService('notification')->getAllNotifications($page_no,$page_total);

    if(!empty($notificaions)) {
      $notificaions = walk_recursive_remove($notificaions, 'unset_null_children');
      for($i=0;$i<count($notificaions);$i++) {
        $notificaions[$i]['message'] = stripslashes(strip_tags($notificaions[$i]['message']));
        $notificaions[$i]['profile_image'] = image_creator($notificaions[$i]['user_image']);
      }
      $notifications_data = json_encode($notifications);      
    } 
  }  
} else {
  $notifications_data = "Error in request";
}   

// Create a request for the '/createMessage' Web Service
$request = CreateMessageRequest::create()
    ->addNotification(Notification::create()->setContent($notifications_data));

// Call the REST Web Service
$response = $pushwoosh->createMessage($request);

// Check if its ok
if($response->isOk()) {
  print 'Great, my message has been sent !';
} else {
  print 'Oops, the sent failed :-( '; 
  print 'Status code : ' . $response->getStatusCode()." ";
  print 'Status message : ' . $response->getStatusMessage();
}
?>
如果您想检查我包含的名称空间的层次结构,您可以在以下位置进行检查


提前感谢。

您在这行中遇到了问题,因为未定义PW_AUTH&PW_应用程序

// Create a Pushwoosh client
$pushwoosh = Pushwoosh::create()
    ->setApplication(PW_AUTH)
    ->setAuth(PW_APPLICATION);

您必须定义PW_AUTH&PW_应用程序常量,还必须交换它,并且对于setAuth使用PW_应用程序

这里有一个指向Pushwoosh的链接,也许查看该方法的行为将帮助您进行调试。我认为您的问题在于Pushwoosh实例化。我将验证PW_AUTH实际上包含一些数据,它可能是空的。
// Create a Pushwoosh client
$pushwoosh = Pushwoosh::create()
    ->setApplication(PW_AUTH)
    ->setAuth(PW_APPLICATION);