Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
454177c6
Commit
454177c6
authored
Jul 05, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
b1eaeab6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
68 deletions
+46
-68
GeTuiUtils.php
application/chat/utils/GeTuiUtils.php
+46
-68
No files found.
application/chat/utils/GeTuiUtils.php
View file @
454177c6
...
@@ -8,34 +8,38 @@
...
@@ -8,34 +8,38 @@
namespace
app\chat\utils
;
namespace
app\chat\utils
;
define
(
'TL_GETUI_APPID'
,
'A8raBWQxuX9bcVmk3rkWa5'
);
define
(
'TL_GETUI_APPSECRET'
,
'TLNDlz8YsW6J4gexzb4AX3'
);
use
RequestException
;
define
(
'TL_GETUI_APPKEY'
,
'dEC3iu81ZC9XbsVLwoiHA6'
);
define
(
'TL_GETUI_MASTERSECRET'
,
'3NNdfsgjCJ6Rmfr9l0EeI1'
);
define
(
'IGT_APP_ID'
,
'A8raBWQxuX9bcVmk3rkWa5'
);
define
(
'TL_GETUI_HOST'
,
'http://sdk.open.api.igexin.com/apiex.htm'
);
define
(
'IGT_APP_SECRET'
,
'TLNDlz8YsW6J4gexzb4AX3'
);
define
(
'IGT_APP_KEY'
,
'dEC3iu81ZC9XbsVLwoiHA6'
);
define
(
'IGT_MASTER_SECRET'
,
'3NNdfsgjCJ6Rmfr9l0EeI1'
);
define
(
'IGT_HOST'
,
'http://sdk.open.api.igexin.com/apiex.htm'
);
class
GeTuiUtils
class
GeTuiUtils
{
{
/**
* GeTuiUtils constructor.
*/
public
function
__construct
()
public
function
__construct
()
{
{
include_once
(
EXTEND_PATH
.
'GETUI_PHP_SDK
'
.
DS
.
'
IGt.Push.php'
);
include_once
(
EXTEND_PATH
.
'GETUI_PHP_SDK
/
IGt.Push.php'
);
}
}
/**
/**
* 个推
*
* @param $data
* @param $data
* @return array
* @return array
* @throws \Exception
*/
*/
function
push_message_for_one
(
$data
)
function
push_message_for_one
(
$data
)
{
{
$cid
=
$data
[
'device_id'
];
$cid
=
$data
[
'device_id'
];
$igt
=
new
\IGeTui
(
TL_GETUI_HOST
,
TL_GETUI_APPKEY
,
TL_GETUI_MASTER
SECRET
);
$igt
=
new
\IGeTui
(
IGT_HOST
,
IGT_APP_KEY
,
IGT_MASTER_
SECRET
);
//模板
//模板
$template
=
$this
->
onli_all_template
(
$data
[
'touchuan'
],
$data
[
'black_title'
],
$data
[
'content'
]);
$template
=
$this
->
onli
ne
_all_template
(
$data
[
'touchuan'
],
$data
[
'black_title'
],
$data
[
'content'
]);
//个推信息体
//个推信息体
$message
=
new
\IGtSingleMessage
();
$message
=
new
\IGtSingleMessage
();
...
@@ -43,14 +47,15 @@ class GeTuiUtils
...
@@ -43,14 +47,15 @@ class GeTuiUtils
$message
->
set_offlineExpireTime
(
3600
*
12
*
1000
);
//离线时间单位为毫秒,例,两个小时离线为3600*1000*2
$message
->
set_offlineExpireTime
(
3600
*
12
*
1000
);
//离线时间单位为毫秒,例,两个小时离线为3600*1000*2
$message
->
set_data
(
$template
);
//设置推送消息类型
$message
->
set_data
(
$template
);
//设置推送消息类型
$message
->
set_PushNetWorkType
(
0
);
//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
$message
->
set_PushNetWorkType
(
0
);
//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
//接收方
//接收方
$target
=
new
\IGtTarget
();
$target
=
new
\IGtTarget
();
$target
->
set_appId
(
TL_GETUI_APP
ID
);
$target
->
set_appId
(
IGT_APP_
ID
);
$target
->
set_clientId
(
$cid
);
$target
->
set_clientId
(
$cid
);
try
{
try
{
$rep
=
$igt
->
pushMessageToSingle
(
$message
,
$target
);
$rep
=
$igt
->
pushMessageToSingle
(
$message
,
$target
);
}
catch
(
RequestException
$e
)
{
}
catch
(
RequestException
$e
)
{
$requestId
=
$e
.
getRequestId
();
$requestId
=
$e
->
getRequestId
();
$rep
=
$igt
->
pushMessageToSingle
(
$message
,
$target
,
$requestId
);
//失败重发
$rep
=
$igt
->
pushMessageToSingle
(
$message
,
$target
,
$requestId
);
//失败重发
}
}
...
@@ -58,69 +63,34 @@ class GeTuiUtils
...
@@ -58,69 +63,34 @@ class GeTuiUtils
}
}
/**
/**
*
群推
*
推送模板
*
*
* @param $title
* @param $payload
* @param $black_title
* @param $content
* @param $content
* @
param $link
* @
return \IGtTransmissionTemplate
* @
return mixed|null
* @
throws \Exception
*/
*/
function
push_message_for_all
(
$title
,
$content
,
$link
)
function
online_all_template
(
$payload
,
$black_title
,
$content
)
{
$igt
=
new
\IGeTui
(
TL_GETUI_HOST
,
TL_GETUI_APPKEY
,
TL_GETUI_MASTERSECRET
);
$homeurl
=
$this
->
http_host
();
$data
[
'black_title'
]
=
$title
;
$data
[
'content'
]
=
$content
;
$data
[
'touchuan'
]
=
json_encode
([
'title'
=>
$title
,
'content'
=>
$content
,
'type'
=>
'url'
,
'url'
=>
$link
,
'name'
=>
$title
,
'id'
=>
''
,
'imageUrl'
=>
$homeurl
.
'/notice_android_logo.png'
]);
$template
=
$this
->
onli_all_template
(
$data
[
'touchuan'
],
$data
[
'black_title'
],
$data
[
'content'
]);
//个推信息体
//基于应用消息体
$message
=
new
\IGtAppMessage
();
$message
->
set_isOffline
(
true
);
$message
->
set_offlineExpireTime
(
3600
*
12
*
1000
);
//离线时间单位为毫秒,例,两个小时离线为3600*1000*2
$message
->
set_data
(
$template
);
$message
->
set_PushNetWorkType
(
0
);
//设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
//$message->set_speed(1);// 设置群推接口的推送速度,单位为条/秒,例如填写100,则为100条/秒。仅对指定应用群推接口有效。
$appIdList
=
[
TL_GETUI_APPID
];
$message
->
set_appIdList
(
$appIdList
);
$rep
=
$igt
->
pushMessageToApp
(
$message
);
return
$rep
;
}
/**
* 推送模板
* zhuwei
* 2017-11-06
*/
function
onli_all_template
(
$touchuan
,
$black_title
,
$content
)
{
{
$template
=
new
\IGtTransmissionTemplate
();
$template
=
new
\IGtTransmissionTemplate
();
$template
->
set_appId
(
TL_GETUI_APP
ID
);
//应用appid
$template
->
set_appId
(
IGT_APP_
ID
);
//应用appid
$template
->
set_appkey
(
TL_GETUI_APP
KEY
);
//应用appkey
$template
->
set_appkey
(
IGT_APP_
KEY
);
//应用appkey
$template
->
set_transmissionType
(
2
);
//透传消息类型
$template
->
set_transmissionType
(
2
);
//透传消息类型
$template
->
set_transmissionContent
(
$
touchuan
);
//透传内容
$template
->
set_transmissionContent
(
$
payload
);
//透传内容
//APN高级推送
//APN高级推送
$apn
=
new
\IGtAPNPayload
();
$apn
=
new
\IGtAPNPayload
();
$alertmsg
=
new
\DictionaryAlertMsg
();
$alert
_
msg
=
new
\DictionaryAlertMsg
();
$alertmsg
->
body
=
$content
;
//对应的是在线透传的content
$alert
_
msg
->
body
=
$content
;
//对应的是在线透传的content
$alertmsg
->
actionLocKey
=
"打开同联商业"
;
//滑动打开app
$alert
_
msg
->
actionLocKey
=
"打开同联商业"
;
//滑动打开app
$alertmsg
->
locKey
=
$content
;
//锁屏提示下框
$alert
_
msg
->
locKey
=
$content
;
//锁屏提示下框
$alertmsg
->
title
=
$black_title
;
//标题 锁屏标题
$alert
_
msg
->
title
=
$black_title
;
//标题 锁屏标题
$alertmsg
->
titleLocKey
=
$black_title
;
//下拉通知上部框框
$alert
_
msg
->
titleLocKey
=
$black_title
;
//下拉通知上部框框
$alertmsg
->
titleLocArgs
=
[
"TitleLocArg"
];
$alert
_
msg
->
titleLocArgs
=
[
"TitleLocArg"
];
$apn
->
alertMsg
=
$alertmsg
;
$apn
->
alertMsg
=
$alert
_
msg
;
$apn
->
badge
=
1
;
//应用icon上显示的数字
$apn
->
badge
=
1
;
//应用icon上显示的数字
$apn
->
sound
=
""
;
$apn
->
sound
=
""
;
$template
->
set_apnInfo
(
$apn
);
$template
->
set_apnInfo
(
$apn
);
...
@@ -128,7 +98,7 @@ class GeTuiUtils
...
@@ -128,7 +98,7 @@ class GeTuiUtils
}
}
/**
/**
* 对某个人推送消息
-公共
* 对某个人推送消息
*
*
* @param $id
* @param $id
* @param $device_id
* @param $device_id
...
@@ -137,6 +107,7 @@ class GeTuiUtils
...
@@ -137,6 +107,7 @@ class GeTuiUtils
* @param string $type
* @param string $type
* @param $user_id
* @param $user_id
* @return array
* @return array
* @throws \Exception
*/
*/
function
public_push_message_for_one
(
$id
,
$device_id
,
$title
,
$content
,
$type
=
'other'
,
$user_id
)
function
public_push_message_for_one
(
$id
,
$device_id
,
$title
,
$content
,
$type
=
'other'
,
$user_id
)
{
{
...
@@ -156,6 +127,11 @@ class GeTuiUtils
...
@@ -156,6 +127,11 @@ class GeTuiUtils
return
$this
->
push_message_for_one
(
$data
);
return
$this
->
push_message_for_one
(
$data
);
}
}
/**
* 当前域名
*
* @return string
*/
public
function
http_host
()
public
function
http_host
()
{
{
$http_type
=
$http_type
=
...
@@ -175,15 +151,17 @@ class GeTuiUtils
...
@@ -175,15 +151,17 @@ class GeTuiUtils
function
http_request
(
$url
,
$data
=
null
)
function
http_request
(
$url
,
$data
=
null
)
{
{
$curl
=
curl_init
();
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYHOST
,
false
);
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYHOST
,
false
);
curl_setopt
(
$curl
,
CURLOPT_POST
,
1
);
curl_setopt
(
$curl
,
CURLOPT_POST
,
1
);
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
$data
);
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
$data
);
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
1
);
$result
=
curl_exec
(
$curl
);
$result
=
curl_exec
(
$curl
);
if
(
curl_errno
(
$curl
))
{
if
(
curl_errno
(
$curl
))
{
return
'Errno'
.
curl_error
(
$curl
);
return
'Err
or_
no'
.
curl_error
(
$curl
);
}
}
curl_close
(
$curl
);
curl_close
(
$curl
);
return
$result
;
return
$result
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment