Codename One使用PHP推送通知问题

8

我已经在我的应用程序中启用了推送通知,添加了构建提示,在play开发人员控制台上注册了API,在我的服务器上创建和加载了苹果证书。当我在设备上测试应用程序时,它成功地注册了推送通知。然而,我的问题在于尝试发送推送通知。我想通过PHP发送。我使用的代码直接来自开发人员指南。但是这并不起作用...这是我的代码有问题还是我在启用推送通知过程中做错了什么?

<?php

include("config.php");

$args = http_build_query(array( 'certPassword' => 'XXXXXXXX', 'cert' 
=>   
'http://kyven.co.za/mibrand/certificate/XXXX.p12',
'production' => false,
'device' => null, 'packageName' => 'za.co.bonyelo.mibrand', 'email' 
 =>     
'kyri88@gmail.com', 'type' => 1,
'auth' => 'XXXXXXXXXXXXXXXXXXXXXXXXXX',
'body' => 'Test'));
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',   
'content'     
=> $args
) );
$context = stream_context_create($opts);
$response = file_get_contents("https://codename-    
one.appspot.com/sendPushMessage", false, $context);

die(json_encode($response));
?>

如果看到您的帖子的人都不懂PHP,比如我,添加赏金也没有什么帮助。我为您的帖子添加了PHP标签。 - Shai Almog
你收到了哪个响应? - Andrew
@Andrew 它是空的。 - Kyri33
1个回答

3

明白了,这是我使用的代码。

<?php

include("config.php");

$args = http_build_query(array('token' => 'XXXXXXXXXXXXXXXXXXX',
'certPassword' => 'XXXXXXXX', 'cert' =>     
'http://XXXXXXX/XXXXX/XXXXX/Certificates.p12',
'production' => false,
'device' => 'cn1-ios-XXXXXXXXXXXXXXXXXXXXXXXX',
 'packageName' => 'za.co.bonyelo.mibrand', 'email' =>    
'kyri88@gmail.com', 'type' => 1,
'auth' => 'XXXXXXXXXXX',
'body' => 'EAT MY BALLS'));
 $opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',   
'content' => $args
) );
$context = stream_context_create($opts);
$response =   
file_get_contents("https://push.codenameone.com/push/push", false,   
$context);

die(json_encode($response));

 ?>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接