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
df606d2e
Commit
df606d2e
authored
Jul 18, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
聊天
parent
20665918
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
25 deletions
+18
-25
ChatService.php
application/chat/service/ChatService.php
+3
-3
RPush.php
application/chat/utils/RPush.php
+15
-22
No files found.
application/chat/service/ChatService.php
View file @
df606d2e
...
...
@@ -221,11 +221,11 @@ class ChatService
if
(
count
(
$info
)
<=
0
)
{
return
false
;
}
$
target
=
[];
$
push_id
=
[];
foreach
(
$info
as
$item
)
{
array_push
(
$
target
,
$item
[
"push_id"
]);
array_push
(
$
push_id
,
$item
[
"push_id"
]);
}
$rPush
->
send
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$is_user
,
$type
,
$accessToken
,
[
$this
,
'saveSendStatus'
]);
$rPush
->
send
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$is_user
,
$type
,
$accessToken
,
[
$this
,
'saveSendStatus'
]
,
$push_id
);
return
true
;
}
...
...
application/chat/utils/RPush.php
View file @
df606d2e
...
...
@@ -16,9 +16,9 @@ use think\Cache;
*/
class
RPush
{
/**
* 发送消息
*
* @param $user_name
* @param $target_type
* @param $target
...
...
@@ -28,8 +28,9 @@ class RPush
* @param $type
* @param $access_token
* @param $callback
* @param $push_id
*/
public
function
send
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$is_user
,
$type
,
$access_token
,
$callback
)
public
function
send
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$is_user
,
$type
,
$access_token
,
$callback
,
$push_id
)
{
//todo
if
(
Cache
::
get
(
'save_message_num'
))
{
...
...
@@ -45,34 +46,28 @@ class RPush
Cache
::
set
(
'save_message_num'
,
0
);
}
$response
=
$this
->
sendRequestByCurl
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$is_user
,
$type
,
$access_token
);
$response
=
$this
->
sendRequestByCurl
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$is_user
,
$type
,
$access_token
,
$push_id
);
call_user_func_array
([
$callback
[
0
],
$callback
[
1
]
],
[
$response
,
$target
,
$from
,
$msg_content
]);
}
/**
* @param $user_name
* @param $target_type users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
* @param $target 注意这里需要用数组,数组长度建议不大于20,即使只有一个用户,也要用数组 ['u1'],给用户发送时数组元素是用户名,
* 给群组发送时数组元素是groupid
* @param $type //目前只有文本的消息
* @param $msg_content
* @param $target_type //users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
* @param $target //注意这里需要用数组,数组长度建议不大于20,即使只有一个用户,也要用数组 ['u1'],给用户发送时数组元素是用户名,
* 给群组发送时数组元素是groupid
* @param $msg_content //目前只有文本的消息
* @param $from
* @param $is_user
* @param $type
* @param $access_token
* @param $push_id
* @return array
*/
public
function
sendRequestByCurl
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$is_user
,
$type
,
$access_token
)
public
function
sendRequestByCurl
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$is_user
,
$type
,
$access_token
,
$push_id
)
{
$title
=
"收到一条消息"
;
// $arr = array(
// 'target_type' => $target_type,
// 'target' => $target,
// 'msg' => [ "type" => "txt", "msg" => $msg_content ],
// 'from' => $from,
// 'ext' => [ "msg_type" => $type, "user_name" => $user_name ]
// );
$payload
=
json_encode
(
array
(
'title'
=>
$title
,
...
...
@@ -88,17 +83,15 @@ class RPush
'from'
=>
$from
,
"user_name"
=>
$user_name
,
'body'
=>
$msg_content
,
'to_id'
=>
''
,
'from_id'
=>
''
,
'to_id'
=>
$target
,
'from_id'
=>
$from
,
'created_at'
=>
'2018-04-02 13:19:14'
]
));
$pushMessageToIgt
=
new
GeTuiUtils
();
$push_arr
=
$target
;
return
$pushMessageToIgt
->
pushMessageToIgt
(
$push_
arr
,
$title
,
$payload
,
$is_user
);
return
$pushMessageToIgt
->
pushMessageToIgt
(
$push_
id
,
$title
,
$payload
,
$is_user
);
/* $curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
"Accept" => "application/json",
...
...
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