| xqd
@@ -0,0 +1,35 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+namespace App\Http\Controllers\Api;
|
|
|
+
|
|
|
+
|
|
|
+use App\Services\TencentImFriendService;
|
|
|
+use Illuminate\Http\Request;
|
|
|
+use PHPUnit\Util\Exception;
|
|
|
+
|
|
|
+class ChatController extends Controller
|
|
|
+{
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加好友
|
|
|
+ * @param Request $request
|
|
|
+ * @return \Illuminate\Http\JsonResponse|void
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ */
|
|
|
+ public function add_friend(Request $request){
|
|
|
+ try {
|
|
|
+ $user = auth('api')->user();
|
|
|
+ if(empty($request->tencent_im_user_id)){
|
|
|
+ throw new Exception("参数错误");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $tencent_im =new TencentImFriendService();
|
|
|
+ $res = $tencent_im->friendAddItem($user->tencent_im_user_id,$request->tencent_im_user_id);
|
|
|
+ }catch (\Exception $exception){
|
|
|
+ return $this->response->errorForbidden($exception->getMessage());
|
|
|
+ }
|
|
|
+ return response()->json($res);
|
|
|
+ }
|
|
|
+}
|