【问题标题】:error in push notification推送通知错误
【发布时间】:2014-06-05 09:01:20
【问题描述】:

我正在尝试实现城市飞艇,并从简单的 php 代码开始。但它给了我错误。 我的php代码:

<?php
require_once 'vendor/autoload.php';
use UrbanAirship\Airship;
use UrbanAirship\Push as P;

$airship = new Airship("key", "secret");
$response = $airship->push()
    ->setAudience(P\deviceToken(""))
    ->setNotification(P\notification("Hello from php!"))
    ->setDeviceTypes(P\all)
    ->send();

print "Push sent!. Push IDs:" . $response.push_ids;

错误: 致命错误:在 C:\xampp\htdocs\phpProjects\notify\vendor\urbanairship\urbanairship\src\UrbanAirship\AirshipException.php 中,未捕获的异常“UrbanAirship\AirshipException”带有消息“Airship request failed: 401 on POST to https://go.urbanairship.com/api/push/” :17 堆栈跟踪:#0

【问题讨论】:

  • 401 表示 :: 未提供访问凭据,或者它们不正确或不适合您拨打的电话。仔细检查应用程序密钥和密钥,并查看您进行的 API 调用是否需要主密钥。
  • @Sudhir secret 和 master secret 有什么区别??请解释
  • Secret 是用于标识应用程序设置密码的字符串,而 Master Secret 是用于服务器到服务器 API 访问的字符串
  • 401 未经授权。检查标题中的授权。

标签: php urbanairship.com


【解决方案1】:

错误是因为在制作飞艇对象时没有给出keysecret。提供密钥和秘密后问题解决了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-27
    • 2023-03-22
    • 2011-05-31
    • 2013-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多