1
私はurbanairshipで開発アプリケーションを作成し、PHPコードを使用してサーバーからプッシュ通知を送信しようとしました。AppkeyはUrbanairshipでメッセージセンターを使用する資格がありません
マイコード:
define('APPKEY','xxx'); // Your App Key
define('PUSHSECRET', 'ytyy'); // Your Master Secret
define('PUSHURL', 'https://go.urbanairship.com/api/push/');
$notification = array();
$notification['alert'] = "alert";
$platform = array();
array_push($platform, "android"); //comment out if you don't want Android
$richpush = array();
$richpush['title'] = "title";
$richpush['body'] = $message;
if(strlen($deviceToken)>50){
$deviceToken=str_replace(" ","",$deviceToken);
$push = array("audience"=>array("device_token"=>$deviceToken), "notification"=>$notification, "device_types"=>$platform, "message"=>$richpush);
}else{
$deviceToken=str_replace(" ","-",$deviceToken);
$push = array("audience"=>array("apid"=>$deviceToken), "notification"=>$notification, "device_types"=>$platform, "message"=>$richpush);
}
$json = json_encode($push);
$session = curl_init(PUSHURL);
curl_setopt($session, CURLOPT_USERPWD, APPKEY . ':' . PUSHSECRET);
curl_setopt($session, CURLOPT_POST, True);
curl_setopt($session, CURLOPT_POSTFIELDS, $json);
curl_setopt($session, CURLOPT_HEADER, False);
curl_setopt($session, CURLOPT_RETURNTRANSFER, True);
curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Accept: application/vnd.urbanairship+json; version=3;'));
$content = curl_exec($session);
echo "Response: " . $content . "\n";
しかし、私は取得しています:
Response: {"ok":false,"error":"The specified appkey [xxx] is not entitled to use the Message Center.","error_code":403}
任意の助けをいただければ幸いです。
サーバーインテグレーションからプッシュ通知を送信できるようにメッセージセンターが必要ですか?私はこの質問に対して明確な答えを見つけることができません。 – Azimuth
いいえ、メッセージセンターはメッセージセンターメッセージを送信するためにのみ必要です。プッシュ通知は、メッセージセンターメッセージの有無にかかわらず送信できます。 – ralepinski