Beispiel #1
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>";
}
 function pushMessageToSingle($content, $title, $tz_content, $alias)
 {
     $igt = new \IGeTui(NULL, APPKEY, MASTERSECRET, false);
     $template = $this->IGtNotificationTemplateDemo($content, $title, $tz_content);
     //个推信息体
     $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_alias($alias);
     try {
         $rep = $igt->pushMessageToSingle($message, $target);
     } catch (\RequestException $e) {
         $requstId = e . getRequestId();
         $rep = $igt->pushMessageToSingle($message, $target, $requstId);
     }
 }
 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;
 }
Beispiel #4
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);
 }
Beispiel #5
0
//透传内容
$template->set_title($_GET["title"]);
//通知栏标题
$template->set_text($_GET["content"]);
//通知栏内容
$template->set_logo("logo.png");
//通知栏logo
$template->set_logoURL("http://wwww.igetui.com/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);