quickblox를 통해 프로그래밍 방식으로 사용자를 만들고 검색하려고합니다. 지금까지 인증 및 세션 생성을 완료했습니다. 그러나이 단계 후에 사용자를 검색하려고하면 토큰이 필요합니다. 오류가 발생합니다.Quickblox 토큰 누락 오류 PHP
DEFINE('APPLICATION_ID', 16619);
DEFINE('AUTH_KEY', "W4EFMSZx3nQZ7eh");
DEFINE('AUTH_SECRET', "NCp5PyZM9uQvWg4");
// User credentials
DEFINE('USER_LOGIN', "removed");
DEFINE('USER_PASSWORD', "removed");
// Quickblox endpoints
DEFINE('QB_API_ENDPOINT', "https://api.quickblox.com");
DEFINE('QB_PATH_SESSION', "session.json");
DEFINE('users', "users.json");
// Generate signature
$nonce = rand();
$timestamp = time(); // time() method must return current timestamp in UTC but seems like hi is return timestamp in current time zone
$signature_string = "application_id=".APPLICATION_ID."&auth_key=".AUTH_KEY."&nonce=".$nonce."×tamp=".$timestamp."&user[login]=".USER_LOGIN."&user[password]=".USER_PASSWORD;
echo "stringForSignature: " . $signature_string . "<br><br>";
$signature = hash_hmac('sha1', $signature_string , AUTH_SECRET);
// Build post body
$post_body = http_build_query(array(
'application_id' => APPLICATION_ID,
'auth_key' => AUTH_KEY,
'timestamp' => $timestamp,
'nonce' => $nonce,
'signature' => $signature,
'user[login]' => USER_LOGIN,
'user[password]' => USER_PASSWORD
));
// Configure cURL
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, QB_API_ENDPOINT . '/' . QB_PATH_SESSION); // Full path is - https://api.quickblox.com/session.json
curl_setopt($curl, CURLOPT_POST, true); // Use POST
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_body); // Setup post body
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // Receive server response
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
// Execute request and read response
$response = curl_exec($curl);
// Check errors
if ($response) {
$cu = curl_init();
curl_setopt($cu, CURLOPT_URL, QB_API_ENDPOINT . '/' . users);
curl_setopt($cu, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cu, CURLOPT_SSL_VERIFYPEER, FALSE);
$res = curl_exec($cu);
echo $res;
}
내가 JSON 따라서 어떤 도움이 높게 평가 될 것이다
왜 투표해야합니까? –
게시 본 배열에 http 빌드 쿼리를 사용하지 마십시오. Curl은 배열이 전달 될 때 변환을 알고 있습니다. – Anthony