$hxurl = "https://a1.easemob.com/51xxx/aaaa/";/** * Bulk Delete user * Description: Deletes the specified number of ring-mail accounts under an app. The above URL can delete 300 users at a time, the value can be modified to suggest this value in 100-500, not too large * @param $limit = "300" default is 300 * @param $ql Delete condition * If Ql=order+by+created+desc is sorted by creation time (Descending) */function Batchdeleteuser ($limit = "", $QL = ") {g Lobal $hxurl; $url = $hxurl. " Users?limit= ". $limit; if (! empty ($QL)) {$url = $hxurl. " Users?ql= ". $ql. "&limit=". $limit; } $header = Array (_get_token ()); $result = _curl_request ($url, ", $header, $type = ' DELETE '); return $result; }/** * Change user nickname * @param [string] $username [user name] * @param [string] $nickname [user Nickname] * */func tion Editnick ($username, $nickname) {global $hxurl; $formgettoken = $hxurl. " Users/". $username; $body =array ("username" = $username, "nickname" and $nickname,); $patoken =json_encodE ($body); $header = Array (_get_token ()); $result = _curl_request ($formgettoken, $patoken, $header, $type = ' PUT '); return $result; }/** * License Registration Mode | | Bulk Register * * @param $options [' username '] User name * @param $options [' Password '] password * Bulk Register a two-dimensional array */function Accreditregister ($options) {global $hxurl; $formgettoken = $hxurl. " Users "; $header = Array (_get_token ()); $result = _curl_request ($formgettoken, Json_encode ($options), $header); return $result; }//Licensing registered Mode POST/{org_name}/{app_name}/usersfunction registertoken ($username, $pwd, $nickname = ") {global $hxurl; $formgettoken = $hxurl. " Users "; $body =array ("username" = $username, "password" and $pwd, ' nickname ' and $nickname); $patoken =json_encode ($body); $header = Array (_get_token ()); $res = _curl_request ($formgettoken, $patoken, $header); $arrayResult = Json_decode ($res, true); Return$arrayResult;} Reset user Password PUT/{org_name}/{app_name}/users/{username}/passwordfunction changepwdtoken ($nikename, $NEWPWD) {global $ Hxurl; $formgettoken = $hxurl. " users/". $nikename." /password "; $body =array ("newpassword" = $newpwd,); $patoken =json_encode ($body); $header = Array (_get_token ()); $method = "PUT"; $res = _curl_request ($formgettoken, $patoken, $header, $method); $arrayResult = Json_decode ($res, true); return $arrayResult;} Remove delete/{org_name}/{app_name}/users/{username}function Delusertoken ($nikename) {global $hxurl; $formgettoken = $hxurl. " users/". $nikename; $body =array (); $patoken =json_encode ($body); $header = Array (_get_token ()); $method = "DELETE"; $res = _curl_request ($formgettoken, $patoken, $header, $method); $arrayResult = Json_decode ($res, true); return $arrayResult;}
First Get app Admin token POST/{org_name}/{app_name}/tokenfunction _get_token () {Global $hxurl; $formgettoken = $hxurl. " Token "; $body =array ("grant_type" = "client_credentials", "client_id" = "xxxxxxxxxxxxxxxxxxxxx", "Client_secret" and "=" "Xxxxxxxxxxxxxxxxxxxxxx"); $patoken =json_encode ($body); $res = _curl_request ($formgettoken, $patoken); $tokenResult = Array (); $tokenResult = Json_decode ($res, true); Var_dump ($tokenResult); Return "Authorization:bearer". $tokenResult ["Access_token"]; }function _curl_request ($url, $body, $header = Array (), $method = "POST") {Array_push ($header, ' Accept:application/json ‘); Array_push ($header, ' Content-type:application/json '); $ch = Curl_init (); curl_setopt ($ch, curlopt_connecttimeout, 60); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, $method, 1); Switch ($method) {case "GET": curl_setopt ($ch, Curlopt_httpget, true); Break Case "POST": curl_setopt ($ch, curlopt_post,true); Break Case "put": curl_setopt ($ch, Curlopt_customrequest, "put"); Break Case "Delete": curl_setopt ($ch, curlopt_customrequest, "delete"); Break } curl_setopt ($ch, Curlopt_useragent, ' SSTS browser/1.0 '); curl_setopt ($ch, curlopt_encoding, ' gzip '); curl_setopt ($ch, Curlopt_ssl_verifypeer, FALSE); curl_setopt ($ch, Curlopt_ssl_verifyhost, 1); if (Isset ($body {3}) > 0) {curl_setopt ($ch, Curlopt_postfields, $body); } if (count ($header) > 0) {curl_setopt ($ch, Curlopt_httpheader, $header); } $ret = Curl_exec ($ch); $err = Curl_error ($ch); $err = Curl_getinfo ($ch, Curlinfo_http_code); Set the return status code curl_close ($ch); Clear_object ($ch); Clear_object ($body); Clear_object ($header); if ($err) {return $err; } return $ret;}
Ring User Import PHP