я разобрался. В моем случае причина была в вашем API создания сеанса. Документация API говорит использовать [POST] /session.json, но пользователи с этим API не работают в групповом чате. Я использовал /auth.json для создания сеанса и использовал функцию RESTful api, и теперь она работает. Это не проблема с учетной записью. Я думаю, что они должны проверить API или обновить документацию.
Это использование /auth.json api.
function qbGenerateSession() {
// 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=" . QB_APP_ID . "&auth_key=" . QB_AUTH_KEY . "&nonce=" . $nonce . "×tamp=" . $timestamp;
$signature = hash_hmac('sha1', $signature_string , QB_AUTH_SECRET);
//echo $signature;
//echo $timestamp;
// Build post body
$post_body = http_build_query(array(
'application_id' => QB_APP_ID,
'auth_key' => QB_AUTH_KEY,
'timestamp' => $timestamp,
'nonce' => $nonce,
'signature' => $signature,
));
// Configure cURL
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.quickblox.com/auth.json'); // Full path is - https://api.quickblox.com/auth.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);
$token = null;
try {
$authInfo = json_decode($response);
$token = $authInfo->session->token;
}
catch (Exception $e) {
curl_close($curl);
return null;
}
// Close connection
curl_close($curl);
return $token;
}
Что говорят? –