zoukankan      html  css  js  c++  java
  • 个推的消息推送

    <?php

    namespace AppHttpControllers;

    use AppUser;
    use Validator;
    use AppHttpControllersController;
    use LaravelSocialiteFacadesSocialite;
    use IlluminateHttpRequest;
    use IlluminateSupportFacadesCache;
    use IlluminateSupportFacadesDB;
    use IlluminateSupportFacadesCookie;


    class UserThirdPushController extends Controller
    {
        public function pushMessage()
        {
            header("Content-Type: text/html; charset=utf-8");

            require_once(dirname(__FILE__) . '/os-php/' . 'IGt.Push.php');
            require_once(dirname(__FILE__) . '/os-php/' . 'igetui/IGt.AppMessage.php');
            require_once(dirname(__FILE__) . '/os-php/' . 'igetui/IGt.APNPayload.php');
            require_once(dirname(__FILE__) . '/os-php/' . 'igetui/template/IGt.BaseTemplate.php');
            require_once(dirname(__FILE__) . '/os-php/' . 'IGt.Batch.php');
            require_once(dirname(__FILE__) . '/os-php/' . 'igetui/utils/AppConditions.php');

            //http的域名
            define('HOST', 'http://sdk.open.api.igexin.com/apiex.htm');

            define('APPKEY', '');
            define('APPID', '');
            define('MASTERSECRET', '');
            define('CID', '');
            define('DEVICETOKEN', '');
            define('Alias', '请输入别名');

            $this->pushMessageToApp();
        }
            //群推接口案例
            function pushMessageToApp()
            {
                $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);

                $template = $this->IGtTransmissionTemplateDemo();

                //$template = $this->IGtNotificationTemplateDemo();

                //$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);
                $message->set_appIdList($appIdList);
                $rep = $igt->pushMessageToApp($message,"任务组名");

                var_dump($rep);
                echo ("<br><br>");
            }

        function IGtTransmissionTemplateDemo()
        {
            $template =  new IGtTransmissionTemplate();
            $template->set_appId(APPID);//应用appid
            $template->set_appkey(APPKEY);//应用appkey
            $template->set_transmissionType(2);//透传消息类型
            $info       =   DB::table('push_message')->orderBy('id','desc')->select('objectid','userid','title','objtype','content')->first();
            $title      =   $info->title;
            $content    =   htmlspecialchars_decode(html_entity_decode(cleanJs($info->content)));
            $b          =   $info;

            $info   =  json_encode($info);
          /*  var_dump($info);
            exit;*/
            $template->set_transmissionContent($info);//透传内容

            //APN高级推送
            $apn = new IGtAPNPayload();
            $alertmsg=new DictionaryAlertMsg();
            //$alertmsg->body="hebintest22222222";
            $alertmsg->body =   $content;
            $alertmsg->actionLocKey="ActionLockey";
            $alertmsg->locKey="LocKey";
            $alertmsg->locArgs=array("locargs");
            $alertmsg->launchImage="launchimage";
            //IOS8.2 支持
            //$alertmsg->title="phptest";
            $alertmsg->title    =   $title;
            $alertmsg->titleLocKey="TitleLocKey";
            //$alertmsg->titleLocArgs=array("TitleLocArg");

            $alertmsg->titleLocArgs =   $b;

            $apn->alertMsg=$alertmsg;
            $apn->badge=1;//icon角标设置数量
            $apn->sound="";
            $apn->add_customMsg("payload","payload");
            $apn->contentAvailable=1;
            $apn->category="ACTIONABLE";

            //添加自定义数据

            //$alertmsg->addCustomMsg  =   $info;

            $template->set_apnInfo($apn);

            return $template;
        }
        
    }
    ?>

  • 相关阅读:
    测试平台系列(38) 接入github第三方登录(上)
    测试平台系列(37) 运用装饰器给用例加上执行日志
    测试平台系列(36) 使用全局变量
    测试平台系列(35) 编写全局变量管理页面
    OCP 063中文考试题库(cuug内部资料)第16题
    OCP 063中文考试题库(cuug内部资料)第15题
    D. Strange Housing 题解(思维+染色)
    B. Strange Definition 题解(质因子分解+思维)
    F. Euclid's nightmare 题解(MST+思维)
    D. Fragmentation merging 题解(思维)
  • 原文地址:https://www.cnblogs.com/zhangmeilin/p/6774042.html
Copyright © 2011-2022 走看看