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
6fb1ab53
Commit
6fb1ab53
authored
Jan 19, 2018
by
clone
Committed by
hujun
Mar 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
b3390c85
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
107 additions
and
4 deletions
+107
-4
AppChat.php
application/chat/controller/AppChat.php
+10
-1
ChatService.php
application/chat/service/ChatService.php
+2
-2
RPush.php
application/chat/utils/RPush.php
+81
-0
curl_cookie.txt
application/chat/utils/curl_cookie.txt
+1
-1
log.txt
log.txt
+13
-0
No files found.
application/chat/controller/AppChat.php
View file @
6fb1ab53
...
...
@@ -113,13 +113,22 @@ class AppChat extends Basic
*/
public
function
pushMsg
()
{
$params
=
$this
->
params
;
if
(
!
isset
(
$params
[
'target_type'
])
||
!
isset
(
$params
[
'target'
])
||
!
isset
(
$params
[
'type'
])
||
!
isset
(
$params
[
'msg_content'
])
||
!
isset
(
$params
[
'source'
])
||
!
isset
(
$params
[
'is_user'
])
||
!
isset
(
$params
[
'from'
]))
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
}
/* $params = array (
'msg_content' => '看看',
'target_type' => 'users',
'source' => '1',
'from' => 'app_63',
'type' => '1',
'is_user' => '0',
'target' => 'app_64',
);*/
$target_type
=
$params
[
'target_type'
];
// 消息类型 users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
$target
=
$params
[
'target'
];
//接受人 if target_type 群 者表示群id
$source
=
$params
[
'source'
];
//消息来源 1c端app 2b端app 3其他
...
...
application/chat/service/ChatService.php
View file @
6fb1ab53
...
...
@@ -169,10 +169,10 @@ class ChatService
*/
public
function
saveSendStatus
(
$response
,
$target
,
$sender
,
$msg_content
)
{
$response
=
json_decode
(
$response
,
true
);
/*
$response = json_decode($response, true);
$response['time'] = date('Y-m-d H:i:s');
$status = $response['statusCode'] == RPush::PUSH_STATUS_SUCCESS ? MsgStatus::STATUS_SUCCESS : MsgStatus::STATUS_FAILURE;
$this
->
insertPushLog
(
$sender
,
$target
,
$msg_content
,
$status
,
$response
[
'statusMsg'
]);
$this->insertPushLog($sender, $target, $msg_content, $status, $response['statusMsg']);
*/
}
/**
...
...
application/chat/utils/RPush.php
0 → 100644
View file @
6fb1ab53
<?php
namespace
app\chat\utils
;
use
app\chat\consts\ConfigConst
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 17:17
* Intro: 发送消息类
*/
class
RPush
{
/**
* 发送消息
* @param $target_type
* @param $target
* @param $type
* @param $msg_content
* @param $from
* @param $access_token
* @param $callback
*/
public
function
send
(
$target_type
,
$target
,
$type
,
$msg_content
,
$from
,
$access_token
,
$callback
)
{
//todo 这里做算法优化,环信接口有限制,每个时间段最多能推送多少请求
$response
=
$this
->
sendRequestByCurl
(
$target_type
,
$target
,
$type
,
$msg_content
,
$from
,
$access_token
);
call_user_func_array
([
$callback
[
0
],
$callback
[
1
]
],
[
$response
,
$target
,
$from
,
$msg_content
]);
}
/** curl参数拼凑
* @param $target_type users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
* @param $target 注意这里需要用数组,数组长度建议不大于20,即使只有一个用户,也要用数组 ['u1'],给用户发送时数组元素是用户名,
* 给群组发送时数组元素是groupid
* @param $type //目前只有文本的消息
* @param $msg_content
* @param $from
* @param $access_token
* @return \app\chat\utils\CurlResponse|bool
*/
public
function
sendRequestByCurl
(
$target_type
,
$target
,
$type
,
$msg_content
,
$from
,
$access_token
)
{
$arr
=
array
(
'target_type'
=>
$target_type
,
'target'
=>
$target
,
'msg'
=>
[
"type"
=>
$type
,
"msg"
=>
$msg_content
],
'from'
=>
$from
,
);
$data
=
json_encode
(
$arr
);
$curl
=
new
\app\chat\utils\CurlUtil
();
$curl
->
headers
=
[
"Accept"
=>
"application/json"
,
"Content-Type"
=>
"application/json;charset=utf-8"
,
'Authorization'
=>
"Bearer "
.
$access_token
,
];
$curl
->
options
=
[
"CURLOPT_SSL_VERIFYPEER"
=>
0
,
"CURLOPT_SSL_VERIFYHOST"
=>
2
,
];
$url
=
$this
->
buildSendUrl
();
$response
=
$curl
->
post
(
$url
,
$data
);
return
$response
;
}
/**
* 请求api
* @return string
*/
private
function
buildSendUrl
()
{
return
ConfigConst
::
API_PATH
.
ConfigConst
::
ORG_NAME
.
"/"
.
ConfigConst
::
APP_NAME
;
}
}
\ No newline at end of file
application/chat/utils/curl_cookie.txt
View file @
6fb1ab53
...
...
@@ -2,4 +2,4 @@
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
a1.easemob.com FALSE / FALSE 151635
2505
rememberMe deleteMe
a1.easemob.com FALSE / FALSE 151635
6233
rememberMe deleteMe
log.txt
View file @
6fb1ab53
...
...
@@ -245,3 +245,16 @@ response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15038133185</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>1323</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=A83C2D00731E2A9F65F7CAC298B44B09
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
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