Ejemplo n.º 1
0
 /**
  * 对单个应用下的所有用户进行推送,可根据机型,省份,标签过滤推送
  * @param  IGtTemplate  $template           消息模板
  * @param  array        $phone_type_list    手机类型列表,['ANDROID', 'IOS']
  * @param  array        $province_list      省份列表,['福建', '上海']
  * @return array  Array ('result' => ok, 'contentId' => OSA-0714_wlhCOZ7r078DZ5muXRg1Y4 )
  */
 public function pushMessageToApp($template, $phone_type_list, $province_list)
 {
     $igt = new IGeTui(self::API_URL, $this->_appkey, $this->_mastersecret);
     $igt->debug = $this->debug;
     //1. 消息模版:
     // a.TransmissionTemplate: 透传功能模板
     // b.LinkTemplate:         通知打开链接功能模板
     // c.NotificationTemplate:通知透传功能模板
     // d.NotyPopLoadTemplate: 通知弹框下载功能模板
     //$template = IGtNotyPopLoadTemplateDemo();
     //$template = IGtLinkTemplateDemo();
     //$template = IGtNotificationTemplateDemo();
     //$template = IGtTransmissionTemplateDemo();
     //2. 个推信息体
     $message = new IGtAppMessage();
     $message->set_isOffline(true);
     // 是否离线
     $message->set_offlineExpireTime(3600 * 12 * 1000);
     // 离线时间
     $message->set_data($template);
     // 设置推送消息类型
     $message->set_PushNetWorkType(0);
     // 设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
     $message->set_appIdList(array($this->_appid));
     $message->set_phoneTypeList($phone_type_list);
     $message->set_provinceList($province_list);
     $response = $igt->pushMessageToApp($message);
     return $response;
 }
Ejemplo n.º 2
0
 function __construct()
 {
     # 配置
     if (!($tConf = Yaf_Registry::get("config")->getui->default)) {
         exit('redis config error: default');
     }
     $tConf = $tConf->toArray();
     $this->tAppkey = $tConf['appkey'];
     $this->tAppid = $tConf['appid'];
     $this->tMastersecret = $tConf['mastersecret'];
     $this->tHost = $tConf['host'];
     $this->tTaskid = $tConf['taskid'];
     parent::__construct($this->tHost, $this->tAppkey, $this->tMastersecret);
 }
Ejemplo n.º 3
0
 function pushMessageToSingle($cid, $template)
 {
     $igt = new IGeTui($this->host, $this->appkey, $this->masterSecuret);
     //个推信息体
     $message = new IGtSingleMessage();
     $message->set_isOffline(true);
     //是否离线
     $message->set_offlineExpireTime(3600 * 12 * 1000);
     //离线时间
     $message->set_data($template);
     //设置推送消息类型
     $message->set_PushNetWorkType(0);
     //设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
     //接收方
     $target = new IGtTarget();
     $target->set_appId($this->appid);
     $target->set_clientId($cid);
     $rep = $igt->pushMessageToSingle($message, $target);
     if ($rep['result'] == 'ok') {
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
function pushMessageToApp()
{
    $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
    //消息模版:
    // 1.TransmissionTemplate:透传功能模板
    // 2.LinkTemplate:通知打开链接功能模板
    // 3.NotificationTemplate:通知透传功能模板
    // 4.NotyPopLoadTemplate:通知弹框下载功能模板
    //$template = IGtNotyPopLoadTemplateDemo();
    $template = IGtLinkTemplateDemo();
    //$template = IGtNotificationTemplateDemo();
    //    	$template = IGtTransmissionTemplateDemo();
    //个推信息体
    //基于应用消息体
    $message = new IGtAppMessage();
    $message->set_isOffline(true);
    $message->set_offlineExpireTime(3600 * 12 * 1000);
    //离线时间单位为毫秒,例,两个小时离线为3600*1000*2
    $message->set_data($template);
    //	$message->set_PushNetWorkType(1);	//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
    //    $message->set_speed(50);          //控速推送,设置每秒消息的下发量
    $message->set_appIdList(array(APPID));
    //$message->set_phoneTypeList(array('ANDROID'));
    //$message->set_provinceList(array('浙江','北京','河南'));
    //	$message->set_tagList(array('中文'));
    $rep = $igt->pushMessageToApp($message, 'toApp任务别名');
    //根据TaskId设置组名,支持下划线,中文,英文,数字
    var_dump($rep);
    echo "<br><br>";
}
Ejemplo n.º 5
0
function pushMessageToList()
{
    putenv("needDetails=true");
    $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
    //消息模版:
    // 1.TransmissionTemplate:透传功能模板
    // 2.LinkTemplate:通知打开链接功能模板
    // 3.NotificationTemplate:通知透传功能模板
    // 4.NotyPopLoadTemplate:通知弹框下载功能模板
    //$template = IGtNotyPopLoadTemplateDemo();
    //$template = IGtLinkTemplateDemo();
    //$template = IGtNotificationTemplateDemo();
    $template = IGtTransmissionTemplateDemo();
    //个推信息体
    $message = new IGtListMessage();
    $message->set_isOffline(true);
    //是否离线
    $message->set_offlineExpireTime(3600 * 12 * 1000);
    //离线时间
    $message->set_data($template);
    //设置推送消息类型
    //$message->set_PushNetWorkType(0);	//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
    $contentId = $igt->getContentId($message, 'toList');
    //$contentId = $igt->getContentId($message,"toList任务别名功能");	//根据TaskId设置组名,支持下划线,中文,英文,数字
    //接收方1
    $target1 = new IGtTarget();
    $target1->set_appId(APPID);
    //$target1->set_clientId(CID);
    $target1->set_alias(ALIAS);
    $targetList[] = $target1;
    $rep = $igt->pushMessageToList($contentId, $targetList);
    var_dump($rep);
    echo "<br><br>";
}
Ejemplo n.º 6
0
function pushMessageToApp()
{
    $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
    $template = IGtTransmissionTemplateDemo();
    //$template = IGtLinkTemplateDemo();
    //个推信息体
    //基于应用消息体
    $message = new IGtAppMessage();
    $message->set_isOffline(true);
    $message->set_offlineExpireTime(10 * 60 * 1000);
    //离线时间单位为毫秒,例,两个小时离线为3600*1000*2
    $message->set_data($template);
    $appIdList = array(APPID);
    $phoneTypeList = array('ANDROID');
    $provinceList = array('浙江');
    $tagList = array('haha');
    //用户属性
    //$age = array("0000", "0010");
    //$cdt = new AppConditions();
    // $cdt->addCondition(AppConditions::PHONE_TYPE, $phoneTypeList);
    // $cdt->addCondition(AppConditions::REGION, $provinceList);
    //$cdt->addCondition(AppConditions::TAG, $tagList);
    //$cdt->addCondition("age", $age);
    $message->set_appIdList($appIdList);
    //$message->set_conditions($cdt->getCondition());
    $rep = $igt->pushMessageToApp($message, "任务组名");
    var_dump($rep);
    echo "<br><br>";
}
Ejemplo n.º 7
0
 private function android()
 {
     $template = $this->IGtTransmissionTemplateDemo();
     $message = new IGtSingleMessage();
     $message->set_isOffline(true);
     //是否离线
     $message->set_offlineExpireTime(3600 * 12 * 1000);
     //离线时间
     $message->set_data($template);
     //设置推送消息类型
     //接收方
     $target = new IGtTarget();
     $target->set_appId(APPID);
     $target->set_clientId(CID);
     $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
     try {
         $rep = $igt->pushMessageToSingle($message, $target);
         var_dump($rep);
         echo "<br><br>";
     } catch (RequestException $e) {
         $requstId = e . getRequestId();
         $rep = $igt->pushMessageToSingle($message, $target, $requstId);
         var_dump($rep);
         echo "<br><br>";
     }
 }
Ejemplo n.º 8
0
 public function __construct()
 {
     parent::__construct(self::HOST, self::APPKEY, self::MASTERSECRET);
 }
Ejemplo n.º 9
0
 function pushMessageToApp($content, $title, $tz_content)
 {
     $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
     $template = $this->IGtNotificationTemplateDemo($content, $title, $tz_content);
     //个推信息体
     //基于应用消息体
     $message = new \IGtAppMessage();
     $message->set_isOffline(true);
     $message->set_offlineExpireTime(10 * 60 * 1000);
     //离线时间单位为毫秒,例,两个小时离线为3600*1000*2
     $message->set_data($template);
     $appIdList = array(appid);
     $phoneTypeList = array('ANDROID');
     $message->set_appIdList($appIdList);
     $igt->pushMessageToApp($message);
 }
Ejemplo n.º 10
0
 public function pushToSingleByAlias()
 {
     $template = $this->IGtTransmissionTemplateDemo();
     // 个推信息体
     $message = new IGtSingleMessage();
     $message->set_isOffline(true);
     // 是否离线
     $message->set_offlineExpireTime(72 * 3600 * 1000);
     // 离线时间,最大值72小时
     $message->set_data($template);
     // 设置推送消息类型
     $message->set_PushNetWorkType(0);
     // 设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
     // 接收方
     $target = new IGtTarget();
     $target->set_appId(self::APPID);
     $target->set_alias($this->alias);
     //$target->set_clientId('df0e2f1a754c7cf106086307c17a16cb');
     $igt = new IGeTui(self::HOST, self::APPKEY, self::MASTERSECRET);
     return $igt->pushMessageToSingle($message, $target);
 }
Ejemplo n.º 11
0
 public function touchuaniosAction()
 {
     $template = $this->touchuandemo();
     $message = new IGtSingleMessage();
     $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
     $message->set_data($template);
     $ret = $igt->pushAPNMessageToSingle(APPID, DEVICETOKEN, $message);
     var_dump($ret);
     exit;
 }
Ejemplo n.º 12
0
 public function getPush(Request $request)
 {
     header("Content-Type: text/html; charset=utf-8");
     require_once dirname(__FILE__) . '/JiulePush/' . 'IGt.Push.php';
     define('APPKEY', 'w5FhVpAEBcAewXzpmEVHHA');
     define('APPID', '63GHvHb4Qr8cIluoXJF797');
     define('MASTERSECRET', 'CiB2pa7jZn6nhIVOkamyV9');
     define('HOST', 'http://sdk.open.api.igexin.com/apiex.htm');
     define('CID', '');
     //define('CID2','请输入ClientID');
     define('ALIAS', $request->input('userid'));
     $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
     //		$res = $igt->queryAlias(APPID, ALIAS);
     //		dd($res)
     //消息模版:
     // 1.TransmissionTemplate:透传功能模板
     // 2.LinkTemplate:通知打开链接功能模板
     // 3.NotificationTemplate:通知透传功能模板
     // 4.NotyPopLoadTemplate:通知弹框下载功能模板
     //$template = IGtNotyPopLoadTemplateDemo();
     //$template = IGtLinkTemplateDemo();
     //$template = IGtNotificationTemplateDemo();
     //$template = IGtTransmissionTemplateDemo();
     $template = new \IGtNotificationTemplate();
     $template->set_appId(APPID);
     //应用appid
     $template->set_appkey(APPKEY);
     //应用appkey
     $template->set_transmissionType(1);
     //透传消息类型
     $template->set_transmissionContent("测试离线");
     //透传内容
     $template->set_title($request->input('title'));
     //通知栏标题
     $template->set_text($request->input('content'));
     //通知栏内容
     $template->set_logo("logo.png");
     //通知栏logo
     $template->set_logoURL(public_path() . '/images/logo.png');
     //通知栏logo链接
     $template->set_isRing(true);
     //是否响铃
     $template->set_isVibrate(true);
     //是否震动
     $template->set_isClearable(true);
     //通知栏是否可清除
     //个推信息体
     $message = new \IGtSingleMessage();
     $message->set_isOffline(true);
     //是否离线
     $message->set_offlineExpireTime(3600 * 12 * 1000);
     //离线时间
     $message->set_data($template);
     //设置推送消息类型
     $message->set_PushNetWorkType(0);
     //设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
     //接收方
     $target = new \IGtTarget();
     $target->set_appId(APPID);
     //		$target->set_clientId(CID);
     $target->set_alias(ALIAS);
     $rep = $igt->pushMessageToSingle($message, $target);
     if ($rep['result'] == 'ok') {
         $pushlog = new PushLog();
         $pushlog->msgtitle = $request->input('title');
         $pushlog->msgcontent = $request->input('content');
         $pushlog->msgtype = $request->input('userid');
         $pushlog->msgsno = $rep['taskId'];
         $pushlog->msgtime = Carbon::now()->timestamp;
         $pushlog->save();
     }
     return $rep;
 }
Ejemplo n.º 13
0
/**
 * Created by PhpStorm.
 * User: 37036_000
 * Date: 2015/10/14
 * Time: 21:13
 */
header("Content-Type: text/html; charset=utf-8");
require_once dirname(__FILE__) . '/' . 'IGt.Push.php';
define('APPKEY', 'PHD9JWXNy89kmYY9NF7V92');
define('APPID', '7t2rQy5B0w9sXNZN6JJf2');
define('MASTERSECRET', 'Gt19kYh3N88tMRODZp4rH2');
define('HOST', 'http://sdk.open.api.igexin.com/apiex.htm');
define('CID', '');
//define('CID2','请输入ClientID');
define('ALIAS', $_GET['userid']);
$igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
//消息模版:
// 1.TransmissionTemplate:透传功能模板
// 2.LinkTemplate:通知打开链接功能模板
// 3.NotificationTemplate:通知透传功能模板
// 4.NotyPopLoadTemplate:通知弹框下载功能模板
//$template = IGtNotyPopLoadTemplateDemo();
//$template = IGtLinkTemplateDemo();
//$template = IGtNotificationTemplateDemo();
//$template = IGtTransmissionTemplateDemo();
$template = new IGtNotificationTemplate();
$template->set_appId(APPID);
//应用appid
$template->set_appkey(APPKEY);
//应用appkey
$template->set_transmissionType(1);
Ejemplo n.º 14
0
 function pushNotificationMessageToList($title = "alarm", $text = "是的, 您木有看错..这是测试信息", $clientIds)
 {
     $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
     //消息类型 :状态栏链接 点击通知打开网页
     $template = new IGtTransmissionTemplate();
     $template->set_appId(APPID);
     //应用appid
     $template->set_appkey(APPKEY);
     //应用appkey
     $template->set_transmissionType(2);
     //透传消息类型
     $template->set_transmissionContent($text);
     //透传内容
     //个推信息体
     $message = new IGtSingleMessage();
     $message->set_isOffline(true);
     //是否离线
     $message->set_offlineExpireTime(3600 * 12);
     //离线时间
     $message->set_data($template);
     //设置推送消息类型
     $contentId = $igt->getContentId($message);
     //接收方1
     $target1 = new IGtTarget();
     $target1->set_appId(APPID);
     foreach ($clientIds as $clientId) {
         $target1->set_clientId($clientId);
         $targetList[] = $target1;
     }
     if (isset($targetList)) {
         $rep = $igt->pushMessageToList($contentId, $targetList);
     }
     return $rep;
 }