Java评论点赞推送系统

编程入门 行业动态 更新时间:2024-10-19 08:51:41

Java评论点赞推送<a href=https://www.elefans.com/category/jswz/34/1770742.html style=系统"/>

Java评论点赞推送系统

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', '.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');

}

更多推荐

Java评论点赞推送系统

本文发布于:2023-06-27 19:22:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/915861.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:系统   Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!