2016-11-25 36 views
-1

我有这个PHP脚本:Onesignal-PHP到Android

<?php 
 
function sendMessage(){ 
 
$content = array(
 
    "en" => 'text message test' 
 
); 
 

 
$fields = array(
 
    'app_id' => "XXXXXX", 
 
    'included_segments' => array('All'), 
 
    'data' => array("foo" => "bar"), 
 
    'headings' => array("en" => "Test message!!"), 
 
"isAndroid"=>true, 
 
// 'android_group' => 'Tanks', 
 
// 'android_group_message' => array("en" => "message"), 
 
    'contents' => $content 
 
); 
 

 
$fields = json_encode($fields); 
 
print("\nJSON sent:\n"); 
 
print($fields); 
 

 
$ch = curl_init(); 
 
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications"); 
 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 
 
         'Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')); 
 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
 
curl_setopt($ch, CURLOPT_HEADER, FALSE); 
 
curl_setopt($ch, CURLOPT_POST, TRUE); 
 
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); 
 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
 

 
$response = curl_exec($ch); 
 
curl_close($ch); 
 

 
return $response; 
 
} 
 

 
$response = sendMessage(); 
 
?>

但就是没有结束notifactions向Android用户。有没有一个例子发送pushnotifications从PHP到OneSignal到android devies?

+2

欢迎来到堆栈溢出!请参考[游览](http://stackoverflow.com/tour),环顾四周,并阅读[帮助中心](http://stackoverflow.com/help),特别是_ [我如何问一个好问题?](http://stackoverflow.com/help/how-to-ask)_。你不清楚你在上面问什么,你可以编辑你的问题来澄清? – Cagy79

回答

0

那么,我没有添加我的一个sognal验证码;)