Пример #1
0
function pushMessageToSingleBatch()
{
    putenv("gexin_pushSingleBatch_needAsync=false");
    $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
    $batch = new IGtBatch(APPKEY, $igt);
    $batch->setApiUrl(HOST);
    //$igt->connect();
    //消息模版:
    // 1.TransmissionTemplate:透传功能模板
    // 2.LinkTemplate:通知打开链接功能模板
    // 3.NotificationTemplate:通知透传功能模板
    // 4.NotyPopLoadTemplate:通知弹框下载功能模板
    //    $template = IGtNotyPopLoadTemplateDemo();
    $template = IGtLinkTemplateDemo();
    //$template = IGtNotificationTemplateDemo();
    //    $template = IGtTransmissionTemplateDemo();
    //个推信息体
    $message = new IGtSingleMessage();
    $message->set_isOffline(true);
    //是否离线
    $message->set_offlineExpireTime(12 * 1000 * 3600);
    //离线时间
    $message->set_data($template);
    //设置推送消息类型
    //    $message->set_PushNetWorkType(1);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
    $target = new IGtTarget();
    $target->set_appId(APPID);
    $target->set_clientId(CID);
    $batch->add($message, $target);
    try {
        $rep = $batch->submit();
        var_dump($rep);
        echo "<br><br>";
    } catch (RequestException $e) {
        $requstId = e . getRequestId();
        $rep = $igt->pushMessageToSingle($message, $target, $requstId);
        var_dump($rep);
        echo "<br><br>";
    }
}
Пример #2
0
 function pushMessageToSingleBatch()
 {
     require_once __ROOT__ . '/ThinkPHP/Library/Vendor/getuiDemo/IGt.Push.php';
     require_once __ROOT__ . '/ThinkPHP/Library/Vendor/getuiDemo/igetui/IGt.AppMessage.php';
     require_once __ROOT__ . '/ThinkPHP/Library/Vendor/getuiDemo/igetui/IGt.APNPayload.php';
     require_once __ROOT__ . '/ThinkPHP/Library/Vendor/getuiDemo/igetui/template/IGt.BaseTemplate.php';
     require_once __ROOT__ . '/ThinkPHP/Library/Vendor/getuiDemo/IGt.Batch.php';
     define('APPKEY', '');
     define('APPID', '');
     define('MASTERSECRET', '');
     define('HOST', 'http://sdk.open.api.igexin.com/apiex.htm');
     define('CID', '');
     define('DEVICETOKEN', '');
     define('Alias', '请输入别名');
     putenv("gexin_pushSingleBatch_needAsync=false");
     $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
     $batch = new \IGtBatch(APPKEY, $igt);
     $batch->setApiUrl(HOST);
     //$igt->connect();
     //消息模版:
     // 1.TransmissionTemplate:透传功能模板
     // 2.LinkTemplate:通知打开链接功能模板
     // 3.NotificationTemplate:通知透传功能模板
     // 4.NotyPopLoadTemplate:通知弹框下载功能模板
     //    $template = IGtNotyPopLoadTemplateDemo();
     $template = IGtLinkTemplateDemo();
     //$template = IGtNotificationTemplateDemo();
     //    $template = IGtTransmissionTemplateDemo();
     //个推信息体
     $message = new \IGtSingleMessage();
     $message->set_isOffline(true);
     //是否离线
     $message->set_offlineExpireTime(12 * 1000 * 3600);
     //离线时间
     $message->set_data($template);
     //设置推送消息类型
     //    $message->set_PushNetWorkType(1);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
     $target = new \IGtTarget();
     $target->set_appId(APPID);
     $target->set_clientId(CID);
     $batch->add($message, $target);
     try {
         $rep = $batch->submit();
         var_dump($rep);
         echo "<br><br>";
     } catch (Exception $e) {
         $rep = $batch->retry();
         var_dump($rep);
         echo "<br><br>";
     }
 }