• 推送(评论,点赞,关注)


     public function push_message($v_uid = "", $uid = "", $type = 1,$message='')
        {
            $data['type'] = $type;
            $openid = $this->get_openid($v_uid);
            $body="";
            switch ($type) {
                case 1;
                    $title = "评论通知";
                    $data['time'] = time();
                    $data['data'] = $message;
                    $data['user_data'] = get_user_info($uid, 'uid,head_img,nickname');
                  //  print_r($data['user_data']);exit;
                   $body = $data['user_data']['nickname'] . "回复了您";
                    break;
                case 2;//系统推送
                    $title='养生推送';
                    break;
            }
            $data = json_encode($data);
            $this->pushMessageToSingle($openid, $data,0,$title,$body);
        }
    
        /**单推接口案例
         * @param $clientId
         * @param $data
         * @param int $type
         * @param $title
         * @param $body
         * @return Array
         */
        function pushMessageToSingle($clientId, $data, $type = 0, $title,$body)
        {
            //消息推送Demo
            header("Content-Type: text/html; charset=utf-8");
            define('HOST', 'http://sdk.open.api.igexin.com/apiex.htm');
            define('APPKEY', ?);
            define('APPID', ?);
            define('MASTERSECRET', ?);
            import('api.lib.GETUI.Push');
            //  define('CID','请输入您的CID')
            $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
            $template = $this->IGtTransmissionTemplateDemo($data, $title,$body);
            // $template =$this->IGtNotyPopLoadTemplateDemo();
            //  print_r($data);die;
            //个推信息体
            $message = new IGtSingleMessage();
            $message->set_isOffline(true);//是否离线
            $message->set_offlineExpireTime(3600 * 12 * 1000);//离线时间
            $message->set_data($template);//设置推送消息类型
            $message->set_PushNetWorkType($type);//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
            //接收方
            $target = new IGtTarget();
            $target->set_appId(APPID);
            $target->set_clientId($clientId);
            return $igt->pushMessageToSingle($message, $target);
        }
    
    
    
        function IGtTransmissionTemplateDemo($data, $title,$body)
        {
            $template = new IGtTransmissionTemplate();
            $template->set_appId(APPID);//应用appid
            $template->set_appkey(APPKEY);//应用appkey
            $template->set_transmissionType(2);//透传消息类型
            $template->set_transmissionContent($data);//透传内容
            //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
    
    // 如下有两个推送模版,一个简单一个高级,可以互相切换使用。此处以高级为例,所以把简单模版注释掉。
            //APN简单推送
    //        $apn = new IGtAPNPayload();
    //        $alertmsg=new SimpleAlertMsg();
    //        $alertmsg->alertMsg="";
    //        $apn->alertMsg=$alertmsg;
    //      $apn->badge=2;
    //      $apn->sound="";
    //        $apn->add_customMsg("payload","payload");
    //        $apn->contentAvailable=1;
    //        $apn->category="ACTIONABLE";
    //        $template->set_apnInfo($apn);
    
            //APN高级推送
            $apn = new IGtAPNPayload();
            $alertmsg = new DictionaryAlertMsg();
            $alertmsg->body = "body";
            $alertmsg->actionLocKey = "打开天天养生";
            $alertmsg->locKey = $body;
            $alertmsg->locArgs = array("locargs");
            $alertmsg->launchImage = "launchimage";
    //        IOS8.2 支持
            $alertmsg->titleLocKey = $title;
            $alertmsg->titleLocArgs = array("TitleLocArg");
    
            $apn->alertMsg = $alertmsg;
            $apn->badge = 1;
            $apn->sound = "";
            $apn->add_customMsg("payload", $data);
    //        $apn->contentAvailable=1;
            $apn->category = "ACTIONABLE";
            $template->set_apnInfo($apn);
    
            return $template;
        }
    
        /**
         * 返回c_id
         * @param $v_uid
         * @return array|mixed|null
         */
        private function get_openid($v_uid){
           return  M('member')->where(['uid'=>$v_uid])->getField('c_id');
        }
    
  • 相关阅读:
    Myeclipse2013 SVN安装方法以及项目上传到svn服务器
    Gson把json串转换成java实体对象
    使用HttpClient向服务器发送restful post请求
    使用HttpURLConnection向服务器发送post和get请求
    http://www.ibm.com/developerworks/cn/opensource/os-cn-cas/
    CAS单点登录配置[5]:测试与总结
    CAS单点登录配置[4]:客户端配置
    CAS单点登录配置[3]:服务器端配置
    CAS单点登录配置[2]:证书生成
    【Oracle/Java】向三张表各插入百万数据,共用时18分3秒,平均每张表6分钟
  • 原文地址:https://www.cnblogs.com/yunian/p/6047769.html
Copyright © 2020-2023  润新知