when we want to sinup in discourse and write a username, if the username is taken, discourse suggest for another username. I wanted to use this feature in my apis and tracked down the api call made by discourse using this topic.
It seems I should do somthing like the following, however when I test it with postman, I dont get the correct response:
This is also the php code I wrote for this:
$discourse_url = 'https://myforum.com/'; $api_user = 'xxxx'; $api_key = 'yyyy'; $username = 'zzz'; $email = 'email@example.com' $data = array( 'api_key'=>$api_key, 'api_username'=>$api_user, 'username'=>$username, 'email'=>$email); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $discourse_url."u/check_username?".http_build_query($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPGET, 1); $response = curl_exec($ch); echo $response;