public function checkChatroom() { $input = Request::all(); $title = $input[1]; //$email = '*****@*****.**'; //$password = '******'; $result = Chatroom::where('title', $title)->get(); return $result->count(); }
| */ use App\Chat; use App\Chatroom; use Illuminate\Http\Request; $app->get('/', function () use($app) { return $app->welcome(); }); /** * Games * Sport * Finance * Animals */ $app->get('chatrooms/{category}', function ($category) { $chatrooms = Chatroom::where('category', $category)->get(); return $chatrooms; }); $app->post('chatrooms', function (Request $request) { $chatroom = Chatroom::create($request->all()); return $chatroom; }); $app->post('chatrooms/{id}/chat', function (Request $request, $chatroomId) { $chatroom = Chatroom::find($chatroomId); $chat = new Chat($request->all()); $chatroom->chats()->save($chat); return $chat; }); $app->get('chatrooms/{id}/chat', function ($chatroomId) { return Chat::where('chatroom_id', $chatroomId)->get(); });
public function putChatroomFriends($wxuin, $post) { \DB::reconnect(); //确保获取了一个新的连接。 //循环执行心跳 $user = Login::where('wxuin', $wxuin)->where('status', 1)->first(); if (!$user) { $this->death(); } $cookies = json_decode($user->cookies); $url = 'https://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/webwxbatchgetcontact?type=ex&r=' . t(); $ret = CURL::send($url, ['Cookie' => urldecode(http_build_query($cookies, '', '; '))], [], ['ret' => 'all', 'post' => json_encode($post)]); $html = $ret->body; $cookies2 = toCookies($ret->cookies); $cookies = (object) ((array) $cookies2 + (array) $cookies); $html = iconv('UTF-8', 'UTF-8//IGNORE', $html); $data_arr = json_decode($html, true); foreach ($data_arr['ContactList'] as $k => $v) { //获取好友信息 $data_room = ['EncryChatRoomId' => $v['EncryChatRoomId'], 'Uin' => $v['Uin'], 'UserName' => $v['UserName'], 'NickName' => $v['NickName'], 'HeadImgUrl' => $v['HeadImgUrl'], 'RemarkName' => $v['RemarkName'], 'Sex' => $v['Sex'], 'Signature' => $v['Signature'], 'AttrStatus' => $v['AttrStatus'], 'Province' => $v['Province'], 'City' => $v['City']]; $rm = Chatroom::where('EncryChatRoomId', $v['EncryChatRoomId'])->where('UserName', $v['UserName'])->first(); //如果存在了就更新 if ($rm) { Chatroom::where('EncryChatRoomId', $v['EncryChatRoomId'])->where('UserName', $v['UserName'])->update($data_room); } else { $data_room_batch[] = $data_room; } } if (isset($data_room_batch)) { Chatroom::insert($data_room_batch); } }