function getOpenImUser($userids) { global $c; $req = new OpenimUsersGetRequest(); $req->setUserids($userids); $resp = $c->execute($req); print_r($resp); }
public function getImUsers($user_ids) { $client = $this->getClient(); $req = new \OpenimUsersGetRequest(); $req->setUserids($user_ids); $resp = $client->execute($req); return $resp; }
$password = isset($requestBody['password']) && $requestBody['password'] != '' ? md5($requestBody['password']) : ''; $userinfo->userid = $username; $userinfo->password = $password; $requset->setUserinfos(json_encode($userinfo)); $response = $client->execute($requset); $responseArray = objectToArray($response); if (isset($responseArray['uid_succ']['string']) && $responseArray['uid_succ']['string'] == $userinfo->userid) { //判断是否注册成功,直接返回密码,用来登录,也就是credential echo json_encode(array('msg' => 'success register', 'code' => 'success', 'username' => $userinfo->userid, 'password' => $userinfo->password)); } else { throw new \Exception(json_encode($responseArray)); // echo json_encode($responseArray); } }); $app->post('/login', function () use($client) { $request = new OpenimUsersGetRequest(); $requestBody = json_decode(@file_get_contents('php://input'), true); if ($requestBody == null) { $username = isset($_POST['username']) ? $_POST['username'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; } else { $username = isset($requestBody['username']) ? $requestBody['username'] : ''; $password = isset($requestBody['password']) ? $requestBody['password'] : ''; } $request->setUserids($username); $response = $client->execute($request); $responseArray = objectToArray($response); if (isset($responseArray['userinfos']['userinfos']['password']) && $responseArray['userinfos']['userinfos']['password'] === md5($password)) { //判断是否注册成功,如果成功就返回密码什么的,可以用来登录 echo json_encode($responseArray['userinfos']['userinfos']); } else {
public function getUser($uid) { $req = new OpenimUsersGetRequest(); $req->setUserids($uid); return $this->c->execute($req); }