laravel 框架接入环信遇到的坑(-)
在脚本中执行判断user表中是否注册环信时,报错: “请求错误:service_resource_not_found Service resource not found ”
// 判断环信是否已经注册该用户 $personal = Easemob::getUser($user->id); dd($personal);
追踪到composer包中link1st\laravel-easemob\src\app\Http.php 文件,添加一行 return false;即可;
public function index() { $userList = User::where('remarks', 'like', '%0417%')->get(); $registers = array(); $num = 0; foreach ($userList as $key => $user) { // 判断环信是否已经注册该用户 $personal = Easemob::getUser($user->id); // dd($personal); if (!$personal) { $registers[] = array('username' => $user->id, 'password' => $user->id . 'laizheer'); $num++; } // 够50条的时候发起注册 if (!empty($registers) and (count($registers) == 50)) { Easemob::authorizationRegistrations($registers); $registers = array(); $this->info('user注册已完成' . $num . '个'); } // 循环到最后一条的时候,直接注册 if (!empty($registers) and ($userList->count() - $key) < 50) { Easemob::authorizationRegistrations($registers); $registers = array(); $this->info('user注册最后已完成' . $num . '个'); } // dd('停止一下'); } dd('总人数:' . count($userList)); }
赞赏码
非学,无以致疑;非问,无以广识