我正在尝试实施城市飞艇,并从简单的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中显示消息'UrbanAirship \ AirshipException',消息'飞艇请求失败:401发送到https://go.urbanairship.com/api/push/' .php:17堆栈跟踪:#0
答案 0 :(得分:0)
错误是因为在制作飞艇对象时没有给出key
和secret
。提供密钥和秘密后,问题得以解决