云客服的畅聊订单消息发送的FaceBook安卓端终端协议的对接以及获取小号所在服务器是否在线的整合信息发送进行优化
正在显示
1 个修改的文件
包含
18 行增加
和
10 行删除
| @@ -69,26 +69,33 @@ class TestKafkaSend extends BaseController | @@ -69,26 +69,33 @@ class TestKafkaSend extends BaseController | ||
| 69 | $taskId = Cache::inc('taskId'); | 69 | $taskId = Cache::inc('taskId'); |
| 70 | // 缓存taskId与消息ID | 70 | // 缓存taskId与消息ID |
| 71 | Cache::set('taskId_'.$taskId,array($res['msgId'],$res['theme']), 300); | 71 | Cache::set('taskId_'.$taskId,array($res['msgId'],$res['theme']), 300); |
| 72 | - $data_data = array('type' => $res['type'], 'taskId' => $taskId, 'wxid' => $res['wxid'], 'date' => time(), 'data' => isset($res['data'])?$res['data']:'', 'timeInMillis' => time()); | 72 | + // $data_data = array('type' => $res['type'], 'taskId' => $taskId, 'wxid' => $res['wxid'], 'date' => time(), 'data' => isset($res['data'])?$res['data']:'', 'timeInMillis' => time()); |
| 73 | + $data_data = array('type' => $res['type'], 'taskId' => $taskId, 'username' => $res['username'], 'date' => time(), 'data' => isset($res['data'])?$res['data']:'', 'timeInMillis' => time()); | ||
| 74 | + trace('data_data ->-> : '.json_encode(array($data_data),JSON_UNESCAPED_UNICODE)); | ||
| 73 | $data = array('data' => json_encode(array($data_data),JSON_UNESCAPED_UNICODE),'type' => 'task'); | 75 | $data = array('data' => json_encode(array($data_data),JSON_UNESCAPED_UNICODE),'type' => 'task'); |
| 76 | + trace('data ->-> : '.json_encode($data,JSON_UNESCAPED_UNICODE)); | ||
| 74 | //取出name对应的服务端ID | 77 | //取出name对应的服务端ID |
| 75 | - $id = $this->isOnline($res['wxid']); | ||
| 76 | - trace('取出name对应得服务端ID: '.$id,'test_consumer'); | 78 | + // $id = $this->isOnline($res['wxid']); |
| 79 | + // trace('取出name对应得服务端ID: '.$id,'test_consumer'); | ||
| 77 | 80 | ||
| 78 | - if (!$id) { $isFackbookOnline = true; } | 81 | + // if (!$id) { $isFackbookOnline = true; } |
| 79 | } | 82 | } |
| 80 | //打日志组包后的消息 | 83 | //打日志组包后的消息 |
| 81 | - trace(json_encode(array('id'=>$id, 'message'=>$data),JSON_UNESCAPED_UNICODE),'test_consumer'); | 84 | + // trace(json_encode(array('id'=>$id, 'message'=>$data),JSON_UNESCAPED_UNICODE),'test_consumer'); |
| 85 | + trace(json_encode(array($data),JSON_UNESCAPED_UNICODE),'test_consumer'); | ||
| 86 | + fwrite($client, json_encode(array($data),JSON_UNESCAPED_UNICODE)."\n"); | ||
| 87 | + // 读取推送结果 | ||
| 88 | + $res = str_replace("\n","",fread($client, 8192)); | ||
| 82 | //判断是否存在服务器id | 89 | //判断是否存在服务器id |
| 83 | - if($id){ | 90 | + /*if($id){ |
| 84 | // 发送数据,注意5678端口是Text协议的端口,Text协议需要在数据末尾加上换行符 | 91 | // 发送数据,注意5678端口是Text协议的端口,Text协议需要在数据末尾加上换行符 |
| 85 | fwrite($client, json_encode(array('id'=>$id, 'message'=>$data),JSON_UNESCAPED_UNICODE)."\n"); | 92 | fwrite($client, json_encode(array('id'=>$id, 'message'=>$data),JSON_UNESCAPED_UNICODE)."\n"); |
| 86 | // 读取推送结果 | 93 | // 读取推送结果 |
| 87 | $res = str_replace("\n","",fread($client, 8192)); | 94 | $res = str_replace("\n","",fread($client, 8192)); |
| 88 | - }else{ | 95 | + }*//*else{ |
| 89 | // 判断facebook是否是登录状态进行一系列的判断 | 96 | // 判断facebook是否是登录状态进行一系列的判断 |
| 90 | - $res = $this->isFackbookOnline($isFackbookOnline, $res); | ||
| 91 | - } | 97 | + // $res = $this->isFackbookOnline($isFackbookOnline, $res); |
| 98 | + }*/ | ||
| 92 | // 打印发送消息返回LOG | 99 | // 打印发送消息返回LOG |
| 93 | trace($res,'test_consumer'); | 100 | trace($res,'test_consumer'); |
| 94 | }else{ | 101 | }else{ |
| @@ -96,6 +103,7 @@ class TestKafkaSend extends BaseController | @@ -96,6 +103,7 @@ class TestKafkaSend extends BaseController | ||
| 96 | } | 103 | } |
| 97 | } | 104 | } |
| 98 | 105 | ||
| 106 | + // 发送facebook发送消息请求 | ||
| 99 | public function isFackbookOnline($isFackbookOnline, $res) { | 107 | public function isFackbookOnline($isFackbookOnline, $res) { |
| 100 | $result = 'false'; | 108 | $result = 'false'; |
| 101 | if ($isFackbookOnline != true) { | 109 | if ($isFackbookOnline != true) { |
| @@ -157,7 +165,7 @@ class TestKafkaSend extends BaseController | @@ -157,7 +165,7 @@ class TestKafkaSend extends BaseController | ||
| 157 | } | 165 | } |
| 158 | } | 166 | } |
| 159 | 167 | ||
| 160 | - // 发送Post请求判断fackbook在线状态 | 168 | + // 发送Post请求 |
| 161 | public function postCurl($url, $postdata) { | 169 | public function postCurl($url, $postdata) { |
| 162 | $header = [ | 170 | $header = [ |
| 163 | 'Content-Type: application/json', | 171 | 'Content-Type: application/json', |
-
请 注册 或 登录 后发表评论