Commit 6fb1ab53 authored by clone's avatar clone Committed by hujun

bug

parent b3390c85
......@@ -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其他
......
......@@ -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']);*/
}
/**
......
<?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
......@@ -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 1516352505 rememberMe deleteMe
a1.easemob.com FALSE / FALSE 1516356233 rememberMe deleteMe
......@@ -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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment