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
e3cbc6f6
Commit
e3cbc6f6
authored
Jan 19, 2018
by
clone
Committed by
hujun
Mar 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
b118d28c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
199 additions
and
0 deletions
+199
-0
AppChat.php
application/chat/controller/AppChat.php
+121
-0
log.txt
log.txt
+78
-0
No files found.
application/chat/controller/AppChat.php
0 → 100644
View file @
e3cbc6f6
<?php
namespace
app\chat\controller
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/8
* Time : 16:54
* Intro:
*/
use
app\chat\consts\ErrorCodeConst
;
use
app\chat\extend\Basic
;
use
app\chat\service\ChatService
;
use
app\chat\utils\RPush
;
use
app\extra\RedisPackage
;
use
think\Cache
;
use
Think\Log
;
class
AppChat
extends
Basic
{
/**
* @var RPush
*/
private
$_push
;
//环信接口消息推送
/**
* @var ChatService
*/
private
$_chat
;
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
_push
=
new
RPush
();
$this
->
_chat
=
new
ChatService
();
}
public
function
index
()
{
/*
log 常规日志,用于记录日志
error 错误,一般会导致程序的终止
notice 警告,程序可以运行但是还不够完美的错误
info 信息,程序输出信息
debug 调试,用于调试信息
sql SQL语句,用于SQL记录,只在数据库的调试模式开启时有效
*/
Cache
::
set
(
'name'
,
'121212'
);
echo
Cache
::
get
(
'name'
);
$redis
=
new
RedisPackage
();
$redis
::
set
(
'test'
,
'hello redis'
);
echo
$redis
::
get
(
'test'
);
Log
::
record
(
'日志'
,
'notice'
);
return
null
;
}
/**
* 验证用户角色,生成唯一id
*
* @return \think\Response
*/
public
function
userChat
()
{
/* $params = array(
"user_id" => 2,
"mobile" => "18205625020",
"source" => 2 //1经纪人 2用户
);*/
$params
=
$this
->
params
;
if
(
!
isset
(
$params
[
'user_id'
])
||
!
isset
(
$params
[
'mobile'
])
||
!
isset
(
$params
[
'source'
]))
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
}
$user_id
=
$params
[
'user_id'
];
$mobile
=
$params
[
'mobile'
];
$source
=
$params
[
'source'
];
if
(
!
$user_id
||
!
$mobile
||
!
$source
)
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
}
$only_arr
=
$this
->
_chat
->
register
(
$user_id
,
$mobile
,
$source
);
if
(
$only_arr
[
"code"
]
==
200
)
{
return
$this
->
response
(
"200"
,
"success"
,
[
"only_id"
=>
$only_arr
[
"only_id"
]
]);
}
else
{
return
$this
->
response
(
"101"
,
$only_arr
[
"msg"
]);
}
}
public
function
pushMsg
()
{
$params
=
$this
->
params
;
$target_type
=
$params
[
'target_type'
];
// 消息类型 users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
$target
=
$params
[
'target'
];
//发送人 if target_type 群 者表示群id
$type
=
$params
[
'type'
];
//消息类型 1文字 2图片
$msg_content
=
$params
[
'msg_content'
];
$from
=
$params
[
'from'
];
//消息发送人
if
(
!
$target_type
||
!
$target
||
!
$type
||
!
$msg_content
||
!
$from
)
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
}
$result
=
$this
->
_chat
->
sendMsg
(
$target_type
,
$target
,
$type
,
$msg_content
,
$from
,
$this
->
accessToken
);
if
(
count
(
$result
)
>
0
)
{
return
$this
->
response
(
"200"
,
[
"msg"
=>
"消息发送成功"
]);
}
}
}
log.txt
View file @
e3cbc6f6
...
...
@@ -128,3 +128,81 @@ response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15505625080</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>4796</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=F413CF2011A6A1505C3B9F4FDD6A2258
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15505625090</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>8999</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=F41DBC75A64B489C3754C87B65A2E09E
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18205625070</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7889</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=905D65B26C5DEF1EC630B0F5AA17A509
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>15505625060</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>3182</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=76D08F08B4D1BAD08457BC638BBDB484
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18805625020</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>2071</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=7058E44B5B45924D7B11C38F5D534306
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756252570</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>9183</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=1A0FD455A35089B0EB5E6723190A15FB
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