namespace IGeTuics;

//增加ClientId可自定义别名功能

header("Content-Type: text/html; charset=utf-8");

require_once(dirname(FILE) . '/' . 'IGt.Push.php');

require_once(dirname(FILE) . '/' . 'IGt.Batch.php');

class alias_demo{

private $APPKEY = 'LlDnps2T6j5Oe3Qi9DdJhA'; // appkey

private $APPID = 'OFhD1n1bLq8uUIraSGv5pA'; // appid

private $MASTERSECRET = 'DG1BieV7b07ez3lJQniQX7'; // master_secret

private $CID = '5bca081ec28f85f91530bf60f55d9870'; // 设备标识

private $Alias = ''; // 用户别名

private $HOST = 'http://sdk.open.api.igexin.com/apiex.htm';

public function __construct($app_key=null, $master_secret=null,$app_id=null) {

// if ($app_key) $this->APPKEY = $app_key;

// if ($master_secret) $this->MASTERSECRET = $master_secret;

// if ($app_id) $this->APPID = $app_id;

}

//pushMessageToSingle();

// pushMessageToList(); // 多推接口

//aliasBind(); // ClientID与别名绑定

//aliasBatch(); // 多个ClientID,使用同一别名绑定

//queryCID(); // 根据别名查询ClientId

//queryAlias(); // 根据ClientId查询别名

//aliasUnBind(); // 解除ClientId别名绑定

//aliasUnBindAll(); // 解除所有ClientId别名绑定

/**

* ClientID与别名绑定

* [aliasBind description]

* @Author 念天地之悠悠

* @DateTime 2020-03-19

* @param [type] $cid [description] 用户设备标识

* @param [type] $alias [description] 用户别名

* @return [type] [description]

*/

function aliasBind($cid,$alias){

$igt = new \IGeTui($this->HOST,$this->APPKEY,$this->MASTERSECRET);

$rep = $igt->bindAlias($this->APPID,$alias,$cid);

return $rep;

}

/**

* 多个ClientID,使用同一别名绑定

* [aliasBatch description]

* @Author 念天地之悠悠

* @DateTime 2020-03-19

* @param [type] $alias [description] 别名

* @param [type] $cid_list [description] cid数组

* @return [type] [description]

*/

function aliasBatch($alias,$cid_list){

$igt = new \IGeTui($this->HOST,$this->APPKEY,$this->MASTERSECRET);

$targetList = [];

foreach ($cid_list as $key => $value) {

$target = new \IGtTarget();

$target->set_clientId($value);

$target->set_alias($alias);

$targetList[] = $target;

}

$rep = $igt->bindAliasBatch($this->APPID,$targetList);

return $rep;

}

/**

* 根据别名查询ClientId

* [queryCID description]

* @Author 念天地之悠悠

* @DateTime 2020-03-19

* @param [type] $alias [description] 用户别名

* @return [type] [description]

*/

function queryCID($alias){

$igt = new \IGeTui($this->HOST,$this->APPKEY,$this->MASTERSECRET);

$rep = $igt->queryClientId($this->APPID,$alias);

return $rep;

}

/**

* 根据ClientId查询别名

* [queryAlias description]

* @Author 念天地之悠悠

* @DateTime 2020-03-19

* @param [type] $cid [description] 用户设备标识

* @return [type] [description]

*/

function queryAlias($cid){

$igt = new \IGeTui($this->HOST,$this->APPKEY,$this->MASTERSECRET);

$rep = $igt->queryAlias($this->APPID,$cid);

return $rep;

}

/**

* 解除ClientId别名绑定

* [aliasUnBind description]

* @Author 念天地之悠悠

* @DateTime 2020-03-19

* @param [type] $alias [description] 用户别名

* @param [type] $cid [description] 用户设备标识

* @return [type] [description]

*/

function aliasUnBind($alias,$cid){

$igt = new \IGeTui($this->HOST,$this->APPKEY,$this->MASTERSECRET);

$rep = $igt->unBindAlias($this->APPID,$alias,$cid);

return $rep;

}

/**

* 解除所有ClientId别名绑定

* [aliasUnBindAll description]

* @Author 念天地之悠悠

* @DateTime 2020-03-19

* @param [type] $cid [description] 用户设备标识

* @param [type] $alias [description] 用户别名

* @return [type] [description]

*/

function aliasUnBindAll($cid,$alias){

$igt = new \IGeTui($this->HOST,$this->APPKEY,$this->MASTERSECRET);

$rep = $igt->unBindAliasAll($this->APPID,$alias,$cid);

return $rep;

}

/**

* 绑定cid标签

* [setClientTag description]

* @Author 念天地之悠悠

* @DateTime 2020-03-19

* @param [type] $cid [description] 用户设备标识

* @param [type] $tag_list [description] 标签数组

*/

function setClientTag($cid,$tag_list){

$igt = new \IGeTui($this->HOST,$this->APPKEY,$this->MASTERSECRET);

$rep = $igt->setClientTag($this->APPID,$cid,$tag_list);

return $rep;

}

//

//服务端推送接口,支持三个接口推送

//1.pushMessageToSingle 接口:支持对单个用户进行推送

//2.pushMessageToList 接口:支持对多个用户进行推送,建议为50个用户

//3.pushMessageToApp 接口:对单个应用下的所有用户进行推送,可根据省份,标签,机型过滤推送

//

/**

* 统一返回数据

* [ret_data description]

* @Author 念天地之悠悠

* @DateTime 2020-03-19

* @param [type] $rep [description]

* @return [type] [description]

*/

function ret_data($rep){

$ret = [];

$ret['code'] = 0;

if ($rep['result'] == 'ok') {

$ret['code'] = 1;

$ret['msg'] = '发送成功!';

}elseif ($rep['result'] == 'sign_error') {

$ret['msg'] = 'sign鉴权失败!';

}elseif ($rep['result'] == 'AppidNoMatchAppKey') {

$ret['msg'] = 'Appid和AppKey不匹配!';

}elseif ($rep['result'] == 'PushTotalNumOverLimit') {

$ret['msg'] = '推送总量超限!';

}elseif ($rep['result'] == 'TokenMD5NoUsers') {

$ret['msg'] = 'cid没有查询到相关用户!';

}elseif ($rep['result'] == 'flow_exceeded') {

$ret['msg'] = '流控!';

}elseif ($rep['result'] == 'TooFrequent') {

$ret['msg'] = '频控!';

}elseif ($rep['result'] == 'AppidError') {

$ret['msg'] = 'appId有误!';

}elseif ($rep['result'] == 'transmissionContent length overlimit') {

$ret['msg'] = '透传内容长度限制!';

}elseif (!strstr($rep['result'],'is not null')) {

$ret['msg'] = '参数校验失败!';

}elseif (!strstr($rep['result'],'Contain Sensitive Word Error')) {

$ret['msg'] = '敏感词受限!';

}elseif ($rep['result'] == 'AliasNotBind') {

$ret['msg'] = '别名没有绑定cid!';

}elseif ($rep['result'] == 'data_too_big') {

$ret['msg'] = '整体数据大小超限!';

}elseif ($rep['result'] == 'target overLimit') {

$ret['msg'] = '批量数量超限!';

}elseif ($rep['result'] == 'NullMsgCommon') {

$ret['msg'] = 'contentId对于的消息体过期或者不存在!';

}elseif ($rep['result'] == 'TaskIdHasBeanCanceled') {

$ret['msg'] = '任务已经被取消!';

}elseif ($rep['result'] == 'NOTarget') {

$ret['msg'] = 'cidList为空!';

}elseif ($rep['result'] == 'PushMsgToListTimesOverLimit') {

$ret['msg'] = 'toList推送总量超限!';

}elseif ($rep['result'] == 'UndefinedContentId') {

$ret['msg'] = '未找到公共体!';

}elseif ($rep['result'] == 'DuplicatedContentId') {

$ret['msg'] = '已经调用过!';

}elseif ($rep['result'] == 'OverLimit') {

$ret['msg'] = 'tag数量超限!';

}elseif ($rep['result'] == 'TagInvalidOrNoAuth') {

$ret['msg'] = '没有有效的tag!';

}elseif ($rep['result'] == 'RepeatedContent') {

$ret['msg'] = '内容重复!';

}elseif ($rep['result'] == 'PushMsgToAppTimesOverLimit') {

$ret['msg'] = 'App群推次数超限!';

}else{

$ret['msg'] = '未知错误!';

}

return $ret;

}

/**

* 单推接口案例

* [pushMessageToSingle description]

* @Author 念天地之悠悠

* @DateTime 2020-03-19

* @param [type] $cid [description] 用户设备标识

* @param [type] $content [description] 透传内容

* @param [type] $title [description] 通知栏标题

* @param [type] $text [description] 通知栏内容

* @param [type] $logo [description] 通知栏logo

* @return [type] [description]

*/

function pushMessageToSingle($cid,$content,$title,$text,$logo){

$cid = $this->CID;

$igt = new \IGeTui($this->HOST,$this->APPKEY,$this->MASTERSECRET);

// 消息模版:

// 1.TransmissionTemplate:透传功能模板

// 2.LinkTemplate:通知打开链接功能模板

// 3.NotificationTemplate:通知透传功能模板

// 4.NotyPopLoadTemplate:通知弹框下载功能模板

// $template = IGtNotyPopLoadTemplateDemo();

// $template = IGtLinkTemplateDemo();

$template = $this->IGtNotificationTemplateDemo($content,$title,$text,$logo);

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

//个推信息体

$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($this->CID);

// $target->set_alias(ALIAS);

$rep = $igt->pushMessageToSingle($message,$target);

return $this->ret_data($rep);

}

/**

* 群推

* [pushMessageToApp description]

* @Author 念天地之悠悠

* @DateTime 2020-03-19

* @param [type] $content [description] 穿透内容

* @param [type] $title [description] 通知标题

* @param [type] $text [description] 通知栏内容

* @param [type] $logo [description] 通知栏logo

* @param [type] $phoneType [description] 手机机型数组 ANDROID IOS

* @param [type] $province [description] 地区编号数组

* @param [type] $tag [description] 设备标签数组

* @return [type] [description]

*/

function pushMessageToApp($content,$title,$text,$logo,$phoneType=null,$province=null,$tag=null){

$igt = new \IGeTui($this->HOST,$this->APPKEY,$this->MASTERSECRET);

$template = $this->IGtNotificationTemplateDemo($content,$title,$text,$logo);

$time = (int)date('YmdHi');

//个推信息体

//基于应用消息体

$message = new \IGtAppMessage();

$message->set_isOffline(true);

$message->set_offlineExpireTime($time); //在用户设定的时间点进行推送,格式为年月日时分

$message->set_speed(100); //定速推送,设置setSpeed为100,则全量送时个推控制下发速度在100条/秒左右。

$message->set_PushNetWorkType(0); //设置是否根据WIFI推送消息,2为4G/3G/2G,1为wifi推送,0为不限制推送,在wifi条件下能帮用户充分节省流量

$message->set_offlineExpireTime(10 * 60 * 1000);//离线时间单位为毫秒,例,两个小时离线为3600*1000*2

$message->set_data($template);

$appIdList = array($this->APPID);

if (!empty($phoneType)) {

$phoneTypeList = $phoneType;

}

if (!empty($province)) {

$provinceList = $province;

}

if (!empty($tag)) {

$tagList = $tag;

}

$cdt = new \AppConditions();

if (!empty($phoneType)) {

$cdt->addCondition3('phoneType', $phoneTypeList);

}

if (!empty($province)) {

$cdt->addCondition3('region', $provinceList);

}

if (!empty($tag)) {

$cdt->addCondition3('tag', $tagList);

}

$message->set_appIdList($appIdList);

$message->set_conditions($cdt);

$rep = $igt->pushMessageToApp($message);

return $this->ret_data($rep);

}

//多推接口案例

function pushMessageToList(){

putenv("needDetails=true");

$igt = new \IGeTui($this->HOST,$this->APPKEY,$this->MASTERSECRET);

//消息模版:

// 1.TransmissionTemplate:透传功能模板

// 2.LinkTemplate:通知打开链接功能模板

// 3.NotificationTemplate:通知透传功能模板

// 4.NotyPopLoadTemplate:通知弹框下载功能模板

//$template = IGtNotyPopLoadTemplateDemo();

//$template = IGtLinkTemplateDemo();

$template = $this->IGtNotificationTemplateDemo();

// $template = $this->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($this->APPID);

//$target1->set_clientId($this->CID);

$target1->set_alias($this->ALIAS);

$targetList[] = $target1;

$rep = $igt->pushMessageToList($contentId, $targetList);

var_dump($rep);

echo ("
");

}

//所有推送接口均支持四个消息模板,依次为通知弹框下载模板,通知链接模板,通知透传模板,透传模板

//注:IOS离线推送需通过APN进行转发,需填写 pushInfo 字段,目前仅不支持通知弹框下载功能

// 弹框下载模板

function IGtNotyPopLoadTemplateDemo(){

$template = new \IGtNotyPopLoadTemplate();

$template ->set_appId($this->APPID);//应用appid

$template ->set_appkey($this->APPKEY);//应用appkey

//通知栏

$template ->set_notyTitle("个推");//通知栏标题

$template ->set_notyContent("个推最新版点击下载");//通知栏内容

$template ->set_notyIcon("");//通知栏logo

$template ->set_isBelled(true);//是否响铃

$template ->set_isVibrationed(true);//是否震动

$template ->set_isCleared(true);//通知栏是否可清除

//弹框

$template ->set_popTitle("弹框标题");//弹框标题

$template ->set_popContent("弹框内容");//弹框内容

$template ->set_popImage("");//弹框图片

$template ->set_popButton1("下载");//左键

$template ->set_popButton2("取消");//右键

//下载

$template ->set_loadIcon("");//弹框图片

$template ->set_loadTitle("地震速报下载");

$template ->set_loadUrl("http://dizhensubao.igexin.com/dl/com.ceic.apk");

$template ->set_isAutoInstall(false);

$template ->set_isActived(true);

return $template;

}

//通知链接模板

function IGtLinkTemplateDemo(){

$template = new \IGtLinkTemplate();

$template ->set_appId($this->APPID);//应用appid

$template ->set_appkey($this->APPKEY);//应用appkey

$template ->set_title("标题");//通知栏标题

$template ->set_text("通知内容");//通知栏内容

$template ->set_logo("");//通知栏logo

$template ->set_isRing(true);//是否响铃

$template ->set_isVibrate(true);//是否震动

$template ->set_isClearable(true);//通知栏是否可清除

$template ->set_url("http://www.igetui.com/");//打开连接地址

// iOS推送需要设置的pushInfo字段

//$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage);

//$template ->set_pushInfo("",2,"","","","","","");

return $template;

}

// 应用消息模板

function IGtNotificationTemplateDemo($content,$title,$text,$logo){

$template = new \IGtNotificationTemplate();

$template->set_appId($this->APPID);//应用appid

$template->set_appkey($this->APPKEY);//应用appkey

$template->set_transmissionType(1);//透传消息类型

$template->set_transmissionContent($content);//透传内容

$template->set_title($title);//通知栏标题

$template->set_text($text);//通知栏内容

// $template->set_logo("http://wwww.igetui.com/logo.png");//通知栏logo

$template->set_logo($logo);//通知栏logo

$template->set_isRing(true);//是否响铃

$template->set_isVibrate(true);//是否震动

$template->set_isClearable(true);//通知栏是否可清除

// iOS推送需要设置的pushInfo字段

//$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage);

//$template ->set_pushInfo("test",1,"message","","","","","");

return $template;

}

// 透传消息模板

function IGtTransmissionTemplateDemo(){

$template = new \IGtTransmissionTemplate();

$template->set_appId($this->APPID);//应用appid

$template->set_appkey($this->APPKEY);//应用appkey

$template->set_transmissionType(1);//透传消息类型

$template->set_transmissionContent("测试离线");//透传内容

//iOS推送需要设置的pushInfo字段

//$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage);

//$template ->set_pushInfo("", 0, "", "", "", "", "", "");

return $template;

}

}

?>

个推mastersecret_个推 服务端 SDK相关推荐

  1. VIVO推送接入 OPPO推送接入 客户端+服务端

    老生常谈,推送接入已经不是什么难事,跟着文档走几小时就能搞定.不过我这里还是要记录一下,因为我在接入的时候还是有坑.希望这篇文章可以帮到你. VVIO客户端 厂商推送,无非就是收到推送拉起通知.所以在 ...

  2. sse服务器推送性能,SSE 服务端向客户端推送

    传统的ajax都是由客户端主动去请求,服务端才可以返回数据 而sse是建立一个通道,并且在断线后自动重连,由服务端去推送,不需要客户端去主动请求,只需要建立通道 websocket是双向通信 客户端可 ...

  3. 技术分享 | 【构建服务端SDK】之连接中心统一调用SDK

    源宝导读:微服务架构与传统的单体式方案的最大不同是微服务将应用的核心功能拆分成多项服务.每项服务可以单独构建和部署.服务之间需要互相通信.假设服务间每次通信都需要在调用方编码操作,那么必定会增加很大的 ...

  4. 飞书的聊天信息服务器,飞书服务端SDK java

    飞书开放接口SDK 概述 飞书开放平台,便于企业应用与飞书集成,让协同与管理更加高效,概述 飞书开发接口SDK,便捷调用服务端API与订阅服务端事件,例如:消息&群组.通讯录.日历.视频会议. ...

  5. 淘宝客服务端SDK PHP7版本简单起步教程

    问题说明 使用PHP7 SDK没基础的朋友可能找不到autoload.php文件,导致不能正常使用SDK文件. 服务端SDK下载地址 淘宝客服务端php7 SDK下载地址 https://consol ...

  6. Android安卓原生接支付宝支付PHP服务端SDK

    1.下载支付宝开发助手工具 下载地址:https://opendocs.alipay.com/open/291/introduce 生产密匙 打开开发助手 点击生成密匙,然后点击打开密匙文件路径后可以 ...

  7. 阿里云服务端SDK下载的jar包通过maven命令安装(maven手动安装本地jar包到项目)...

    有些jar包未开源,在maven中央仓库没有未开源的jar包,所以pom文件里不能自动联网下载,可以通过maven命令手动安装本地maven仓库中,手动安装不需要联网,前提是本地已经有要安装的jar包 ...

  8. 免费开源iPhone推送消息工具+服务端-Bark

    什么是Bark Bark 是一款纯推送提醒服务,主要用来给自己的 iPhone 发送自定义内容的推送,可以是文字.链接,不提供历史记录功能,阅后即焚.服务端和客户端均开源,实时性和稳定性都非常可靠,支 ...

  9. 阿里物联网套件-服务端SDK学习实践(基础篇-12推送数据给设备并得到响应)

    推送数据给设备并得到响应 官方链接 特别注意:该接口目前只适用CCP协议接入的设备,MQTT协议不支持 而CCP(目前华东2节点不支持该功能) RevertRpcRequest和RevertRpcRe ...

  10. 第三方服务-阿里云视频点播服务java服务端SDK相关代码

    视频点播服务中的视频,也依然是存在OSS上的,但是区别是什么呢?下面关于区别的描述摘自阿里云官网 视频的点播场景涉及视频的存储.转码.分发加速几个环节,那么: 视频点播是集视频音视频采集.编辑.上传. ...

最新文章

  1. 怎么点亮段码屏_手机被人偷了,支付宝里的钱被转走了,遇到这种情况该怎么办?...
  2. 开机启动加载驱动过程中调用PostMessage函数出错
  3. 打印二叉树的边界节点
  4. 详解虚函数的实现过程之单继承(2)
  5. 双指针算法(四):力扣 88.合并两个有序数组 | 经典例题
  6. nodejs的package.json依赖dependencies中 ^ 和 ~ 的区别
  7. metasploit-***测试工具
  8. HDU - 6333 Harvest of Apples
  9. Wicket实战(二)hello world
  10. org.apache.commons.fileupload.DiskFileUpload1
  11. ads滤波器仿真(2)——带通滤波器
  12. MapServer+OpenLayers5+Vue实现栅格图层数据查询
  13. 网易游戏再出新招:探索人脸识别功能
  14. 【资讯】创业加速器Satoshi Block Dojo——为BSV前沿初创企业的发展提速
  15. jenkins基础知识
  16. 类的封装性、继承性和多态性设计
  17. 电视台音频直播的问题
  18. python 过滤相似图片_Python过滤纯色图片,挑选视频封面
  19. InteractiveGovernor调频策略
  20. Abnormal Activity Detection Using Pyroelectric Infrared Sensors

热门文章

  1. Mufasa: Multimodal Fusion Architecture Search For Electronic Health Records【多模态融合架构 论文笔记】
  2. 大数据处理的五大关键技术及其应用
  3. .NET in China - What's New in .NET
  4. 【BZOJ5316】【JSOI2018】绝地反击
  5. 遭DeFi反噬,以太坊绝地反击 |链捕手
  6. 阿里巴巴字体库使用方法
  7. 计算机模拟自由落体,CSS3 方块自由落体运动模拟
  8. c++编程求解二元二次方程组_c++:求解二元二次方程组(解析解)
  9. win10电脑右键视频或者图片文件卡死
  10. PHP将uncode转utf8,一行代码解决问题