Commit 900ca3c1 authored by hujun's avatar hujun

推送修改

parent 53475b00
...@@ -31,31 +31,30 @@ class GeTuiUtils ...@@ -31,31 +31,30 @@ class GeTuiUtils
/** /**
* 推送消息 * 推送消息
* *
* @param $device_id * @param $push_id
* @param string $type * @param string $type
* @param $title * @param $title
* @param $content * @param $data
* @param null $id
* @return array * @return array
* @throws \Exception
*/ */
public function pushMessageToIgt($device_id, $type = 'other', $title, $content, $id = null) public function pushMessageToIgt($push_id, $type = 'other', $title, $data)
{ {
$igt = new \IGeTui(self::IGT_HOST, self::IGT_APP_KEY, self::IGT_MASTER_SECRET); $igt = new \IGeTui(self::IGT_HOST, self::IGT_APP_KEY, self::IGT_MASTER_SECRET);
$payload['title'] = $title; $payload['title'] = $title;
$payload['content'] = $content; $payload['type'] = $type; //0系统,1用户消息
$payload['type'] = $type; $payload['msg_content'] = $data['msg_content'];
$payload['url'] = ""; $payload['to_id'] = $data['to_id']; //接收人
$payload['name'] = $title; $payload['from_id'] = $data['from_id']; //发送人
$payload['id'] = $id; $payload['to_name'] = $data['to_name'];//接收人名字
$payload['imageUrl'] = ""; $payload['from_name'] = $data['from_name'];//发送人名字
$payload['target_type'] = $data['target_type']; //1文字,2.图片 3.楼盘
$payload = json_encode($payload); $payload = json_encode($payload);
try { try {
//模板 //模板
$template = $this->onlineAllTemplate($payload, $title, $content); $template = $this->onlineAllTemplate($payload, $title, $data['msg_content']);
} catch (\Exception $e) { } catch (\Exception $e) {
$result['code'] = 'failed'; $result['code'] = 'failed';
$result['msg'] = '字数超过限制'; $result['msg'] = '字数超过限制';
...@@ -72,16 +71,21 @@ class GeTuiUtils ...@@ -72,16 +71,21 @@ class GeTuiUtils
//接收方 //接收方
$target = new \IGtTarget(); $target = new \IGtTarget();
$target->set_appId(self::IGT_APP_ID); $target->set_appId(self::IGT_APP_ID);
$target->set_clientId($device_id);
$res = $igt->pushMessageToSingle($message, $target); $result = [];
if ($res['result'] == 'ok') { foreach ($push_id as $k => $v) {
$result['code'] = 'success'; $target->set_clientId($v);
$result['msg'] = $res['result']; $res = $igt->pushMessageToSingle($message, $target);
} else {
$result['code'] = 'failed'; if ($res['result'] == 'ok') {
$result['msg'] = $this->getReturnCode($res['result']); $result['code'] = 'success';
$result['msg'] = $res['result'];
} else {
$result['code'] = 'failed';
$result['msg'] = $this->getReturnCode($res['result']);
break;
}
} }
return $result; return $result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment