2012-08-06 84 views
3

我想在Android设备上使用php发送推送通知, 我正在使用ACS(Appcelerator云服务)。 这里是我的代码,如果有人发现任何解决方案,那么请分享它。需要php代码在Android设备上使用ACS发送推送通知

$tmp_fname = "cookie.txt"; 
$curl_handle = curl_init('https://api.cloud.appcelerator.com/v1/users /login.json?key=uGDhfoFYdIwwyCKQMzKlSuNIPxl3CBSd'); 
curl_setopt($curl_handle, CURLOPT_COOKIEJAR, $tmp_fname); 
curl_setopt($curl_handle, CURLOPT_POST, 1); 
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl_handle, CURLOPT_COOKIEFILE, $tmp_fname); 
$post_array = array('login' => 'abs', 'password' => '123456'); 
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $post_array); 
$output = curl_exec($curl_handle); 
//$session = json_decode($output); 
print_r($output); 
$json = '{"badge": 1,"sound": "default","alert" : "Abdul Sattar Testing"}'; 
$Curl_Session2 = curl_init('https://api.cloud.appcelerator.com/v1/push_notification/notify.json?key=uGDhfoFYdIwwyCKQMzKlSuNIPxl3CBSd&to_ids=ND1TQ9BM8TW4GYASMP2MJ84'); 
curl_setopt($Curl_Session2, CURLOPT_COOKIEFILE, "$tmp_fname"); 
curl_setopt($Curl_Session2, CURLOPT_COOKIEJAR, "$tmp_fname"); 
curl_setopt($Curl_Session2, CURLOPT_POST, 1); 
curl_setopt($Curl_Session2, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($Curl_Session2, CURLOPT_POSTFIELDS, "channel=friend_request&payload=" . $json); 
curl_setopt($Curl_Session2, CURLOPT_FOLLOWLOCATION, 1); 
$res2 = curl_exec($Curl_Session2); 
$response = curl_getinfo($Curl_Session2); 
print_r($res2); 
echo '<br /><br />'; 
print_r($response); 
curl_close($Curl_Session2); 
+0

上面的代码不起作用。 – 2012-08-06 07:22:09

+0

我也曾尝试使用Appacelerator来推送通知。但不幸的是我必须使用本地通知! – 2012-08-06 07:26:01

+0

本地通知是指“In App”还是“Active App”通知? – 2012-08-06 07:39:08

回答

相关问题