码迷,mamicode.com
首页 > Web开发 > 详细

极光推送开发-ThinkPHP集成

时间:2015-08-14 13:06:03      阅读:2553      评论:0      收藏:0      [点我收藏+]

标签:

1. 到极光推送官网下载PHP SDK http://docs.jpush.io/server/php_sdk/ 2. 解压vendor.tar.gz到您的项目,ThinkPHP/Library/Vendor/下 3. 在应用文件夹的home模块Controller下创建一个JpushController文件 Php 代码: ‘; $client = new JPushClient(‘64237c873a665c79b1ece96c‘, ‘41aeddfab4828ddb64a5a1f1‘); try { $result = $client->push() ->setPlatform(M\all) ->setAudience(M\all) ->setNotification(M\notification(‘Hi, JPush‘, M\android(‘Hi, Android‘, ‘Message Title‘, 1,array("key1"=>"value1","key2"=>"value2","key3"=>"value3")) )) ->setMessage(M\message(‘Message Content‘, ‘Message Title1‘, ‘Message Type‘, array("key1"=>"value1","key2"=>"value2","key3"=>"value3"))) ->send(); echo ‘Push Success.‘ . $br; echo ‘sendno : ‘ . $result->sendno . $br; echo ‘msg_id : ‘ .$result->msg_id . $br; echo ‘Response JSON : ‘ . $result->json . $br; } catch (APIRequestException $e) { echo ‘Push Fail.‘ . $br; echo ‘Http Code : ‘ . $e->httpCode . $br; echo ‘code : ‘ . $e->code . $br; echo ‘message : ‘ . $e->message . $br; echo ‘Response JSON : ‘ . $e->json . $br; echo ‘rateLimitLimit : ‘ . $e->rateLimitLimit . $br; echo ‘rateLimitRemaining : ‘ . $e->rateLimitRemaining . $br; echo ‘rateLimitReset : ‘ . $e->rateLimitReset . $br; } catch (APIConnectionException $e) { echo ‘Push Fail.‘ . $br; echo ‘message‘ . $e->getMessage() . $br; } } }

极光推送开发-ThinkPHP集成

标签:

原文地址:http://www.cnblogs.com/52sharing/p/4729586.html

(9)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!