php - 需要 php 代码才能使用 ACS 在 Android 设备上发送推送通知

标签 php android appcelerator-mobile

我想使用 php 在 android 设备上发送推送通知, 为此,我正在使用 ACS(Appcelerator 云服务)。 这是我的代码,如果有人找到任何解决方案,请分享。

$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);

最佳答案

已经试过了? https://developers.google.com/android/c2dm/ 它是云到设备的消息传递。它可以更轻松地创建推送通知。

希望能帮到你 :)

编辑: 也许这也可以帮助你。 http://developer.appcelerator.com/question/137264/php-curl-problem-acs-push-notification

关于php - 需要 php 代码才能使用 ACS 在 Android 设备上发送推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11824014/

相关文章:

php - 在 PHP 中从 MySQL 数据库创建超链接

php - 使用在特定时间后运行的参数设置 cron,然后使用 php 执行完成后删除该 cron 作业

php - 如何检查 View 是否存在?

javascript - Ajax 调用不断失败,但没有错误

android - 如何获取Android应用程序中的当前经纬度?

Android:打开默认音频播放器

android - 由于使用 Titanium 的 Facebook 模块出现无效访问 token 错误,无法登录 Facebook

javascript - Appcelerator 中的自定义选项卡栏 - 如何返回根窗口?

android - 将按钮缩放到屏幕大小

android - 将 Titanium 应用程序转换为模块