编程语言
首页 > 编程语言> > 从PHP通过pushwoosh发送推送通知

从PHP通过pushwoosh发送推送通知

作者:互联网

我正在尝试通过woosh发送推送通知,如下所示:

有人帮助我如何从此代码在设备上发送推送通知

函数pwCall(
 ‘createMessage’,数组(

        'application' => PW_APPLICATION,          

        'auth' => PW_AUTH,

        "devices" => PW_DEVICETOKEN,

        'notifications' =>  array(

                    'send_date' =>'now', //gmdate('d-m-Y H:i', strtotime('2014-04-07 20:35')),

                    'content' => 'my custom notification testing ',

    'link' => 'http://pushwoosh.com/',

                    'content' => array("en" => "English","ru" =>"Русский","de"=>"Deutsch")

                    ),

                  'page_id' => 16863,

                  'link' => 'http://google.com',

                 'data' => array( 'custom' => 'json data' ),   
            )
    );

我收到诸如

数组([status_code] => 210 [status_message] =>无法解析日期[response] =>)

解决方法:

>通知应该是JSON表示法中的对象数组.在PHP中,它将是数组数组.这是因为您可以在一个请求中创建多个通知.
通知的最终JSON字段:

“通知”:[{…通知属性…},{…第二个通知属性…},…]
>请求中只有3个根参数:application(OR applications_group),auth和通知.其他参数是通知参数,不是请求参数.

最后,您的PHP调用应如下所示:

pwCall("createMessage", array(
  "auth" => PW_AUTH,
  "application" => PW_APPLICATION,
  "notifications" => array(
    array(
      "send_date" => "now",
      "content" => array("en" => "English", "ru" =>"Русский", "de"=>"Deutsch"),
      "link" => "http://pushwoosh.com/",
      "page_id" => 16863,
      "devices" => array( PW_DEVICETOKEN ),
      "data" => array( "custom" => "json data" )
    )
  )
));

send_date和content以外的所有通知字段都是可选的,可以省略

标签:push-notification,oauth-2-0,iphone,php,pushwoosh
来源: https://codeday.me/bug/20191121/2054965.html