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
56885084
Commit
56885084
authored
Jul 05, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
方法名修改
parent
454177c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
39 deletions
+47
-39
GeTuiUtils.php
application/chat/utils/GeTuiUtils.php
+47
-39
No files found.
application/chat/utils/GeTuiUtils.php
View file @
56885084
...
...
@@ -26,20 +26,58 @@ class GeTuiUtils
{
include_once
(
EXTEND_PATH
.
'GETUI_PHP_SDK/IGt.Push.php'
);
}
/**
* 对某个人推送消息
*
* @param $id
* @param $device_id
* @param $title
* @param $content
* @param string $type
* @param $user_id
* @return array
* @throws \Exception
*/
public
function
pushToPerson
(
$id
,
$device_id
,
$title
,
$content
,
$type
=
'other'
,
$user_id
=
null
)
{
$home_url
=
$this
->
httpHost
();
$data
[
'agent_id'
]
=
$id
;
$data
[
'black_title'
]
=
$title
;
$data
[
'content'
]
=
$content
;
$data
[
'device_id'
]
=
$device_id
;
$data
[
'touchuan'
]
=
json_encode
([
'title'
=>
$title
,
'content'
=>
$content
,
'type'
=>
$type
,
'url'
=>
''
,
'name'
=>
$title
,
'id'
=>
$user_id
,
'imageUrl'
=>
$home_url
.
'notice_android_logo.png'
]);
try
{
$result
=
$this
->
pushMessageToIgt
(
$data
);
}
catch
(
\Exception
$e
)
{
$result
[
'result'
]
=
'error'
;
$result
[
'status'
]
=
$e
->
getMessage
();
}
return
$result
;
}
/**
* @param $data
* @return array
* @throws \Exception
*/
function
push_message_for_one
(
$data
)
public
function
pushMessageToIgt
(
$data
)
{
$cid
=
$data
[
'device_id'
];
$igt
=
new
\IGeTui
(
IGT_HOST
,
IGT_APP_KEY
,
IGT_MASTER_SECRET
);
//模板
$template
=
$this
->
online
_all_t
emplate
(
$data
[
'touchuan'
],
$data
[
'black_title'
],
$data
[
'content'
]);
$template
=
$this
->
online
AllT
emplate
(
$data
[
'touchuan'
],
$data
[
'black_title'
],
$data
[
'content'
]);
//个推信息体
$message
=
new
\IGtSingleMessage
();
...
...
@@ -71,7 +109,7 @@ class GeTuiUtils
* @return \IGtTransmissionTemplate
* @throws \Exception
*/
function
online
_all_t
emplate
(
$payload
,
$black_title
,
$content
)
function
online
AllT
emplate
(
$payload
,
$black_title
,
$content
)
{
$template
=
new
\IGtTransmissionTemplate
();
...
...
@@ -81,7 +119,7 @@ class GeTuiUtils
$template
->
set_transmissionContent
(
$payload
);
//透传内容
//APN高级推送
$apn
=
new
\IGtAPNPayload
();
$apn
=
new
\IGtAPNPayload
();
$alert_msg
=
new
\DictionaryAlertMsg
();
$alert_msg
->
body
=
$content
;
//对应的是在线透传的content
$alert_msg
->
actionLocKey
=
"打开同联商业"
;
//滑动打开app
...
...
@@ -96,43 +134,13 @@ class GeTuiUtils
$template
->
set_apnInfo
(
$apn
);
return
$template
;
}
/**
* 对某个人推送消息
*
* @param $id
* @param $device_id
* @param $title
* @param $content
* @param string $type
* @param $user_id
* @return array
* @throws \Exception
*/
function
public_push_message_for_one
(
$id
,
$device_id
,
$title
,
$content
,
$type
=
'other'
,
$user_id
)
{
$home_url
=
$this
->
http_host
();
$data
[
'agent_id'
]
=
$id
;
$data
[
'black_title'
]
=
$title
;
$data
[
'content'
]
=
$content
;
$data
[
'device_id'
]
=
$device_id
;
$data
[
'touchuan'
]
=
json_encode
([
'title'
=>
$title
,
'content'
=>
$content
,
'type'
=>
$type
,
'url'
=>
''
,
'name'
=>
$title
,
'id'
=>
$user_id
,
'imageUrl'
=>
$home_url
.
'notice_android_logo.png'
]);
return
$this
->
push_message_for_one
(
$data
);
}
/**
* 当前域名
*
* @return string
*/
public
function
http
_h
ost
()
public
function
http
H
ost
()
{
$http_type
=
((
isset
(
$_SERVER
[
'HTTPS'
])
&&
$_SERVER
[
'HTTPS'
]
==
'on'
)
||
(
isset
(
$_SERVER
[
'HTTP_X_FORWARDED_PROTO'
])
&&
...
...
@@ -148,17 +156,17 @@ class GeTuiUtils
* @param null $data
* @return mixed|string
*/
function
http
_r
equest
(
$url
,
$data
=
null
)
function
http
R
equest
(
$url
,
$data
=
null
)
{
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYHOST
,
false
);
curl_setopt
(
$curl
,
CURLOPT_POST
,
1
);
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
$data
);
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
1
);
$result
=
curl_exec
(
$curl
);
if
(
curl_errno
(
$curl
))
{
return
'Error_no'
.
curl_error
(
$curl
);
...
...
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