首页 > 后端开发 > php教程 > GCM with PHP (Google Cloud Messaging)云推送消息功能的例子

GCM with PHP (Google Cloud Messaging)云推送消息功能的例子

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
发布: 2016-07-25 08:47:29
原创
851 人浏览过
  1. $url = 'https://android.googleapis.com/gcm/send';
  2. $serverApiKey = "YOUR API KEY AS GENERATED IN API CONSOLE";
  3. $reg = "DEVICE REGISTRATION ID";
  4. $data = array(
  5. 'registration_ids' => array($reg),
  6. 'data' => array('yourname' => 'Joe Bloggs'));
  7. print(json_encode($data));
  8. $client = new Zend_Http_Client($url);
  9. $client->setMethod('POST');
  10. $client->setHeaders(array("Content-Type" => "application/json", "Authorization" => "key=" . $serverApiKey));
  11. $client->setRawData(json_encode($data));
  12. $request = $client->request('POST');
  13. $body = $request->getBody();
  14. $headers = $request->getHeaders();
  15. print("");var_dump($body);var_dump($headers);
  16. ?>
复制代码


来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板