Unable to register user on quickblox with PHP cURL

931 views Asked by At

I got token with the session rest call for quickblox.

Now I want to register my user on quickblox, but getting following as response to cURL: {"code":null,"message":"No data was provided"}

I have written following code:

<pre><code>
$token = '66575f5085173718a73d74781223d0bc14e3abb1';
$post_body = http_build_query(array(
                    'login' => 'test1436547745678568768',
                    'password' => 'test1',
                    'email' => '[email protected]',
                    'external_user_id' => '68764641',
                    'facebook_id' => '',
                    'twitter_id' => '',
                    'full_name' => 'test1 test1',
                    'phone' => '',
                    'website' => '',
                    'tag_list' => '',
                    ));

$signUpCurl = curl_init();
curl_setopt($signUpCurl, CURLOPT_URL, self::QB_API_ENDPOINT . '/' . self::QB_PATH_USER);
curl_setopt($signUpCurl, CURLOPT_HTTPHEADER, array("QB-Token: ".$token));
curl_setopt($signUpCurl, CURLOPT_POST, true);
curl_setopt($signUpCurl, CURLOPT_POSTFIELDS, $post_body);
curl_setopt($signUpCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($signUpCurl, CURLOPT_SSL_VERIFYPEER, FALSE);

$responce = curl_exec($signUpCurl);

// Check errors
if ($responce) {
  echo $responce . "\n";
} else {
  $error = curl_error($signUpCurl). '(' .curl_errno($signUpCurl). ')';
  echo $error . "\n";
}

// Close connection
curl_close($signUpCurl);

return ' signUp ';</code>

Please help me to get correct response.

1

There are 1 answers

0
Disc Stunner On

// pass all fields as user array.

$post_body = http_build_query(

array(
    'user'=>array(
        'login' => 'test1436547745678568768',
        'password' => 'test1234',
        'email' => '[email protected]',
        'external_user_id' => '68764641',
        'facebook_id' => '',
        'twitter_id' => '',
        'full_name' => 'test1 test1',
        'phone' => '',
        'website' => '',
        'tag_list' => '',
        )
    )
);