2016-06-21 3 views
1

(자바 스크립트 SDK). 나는 소스 코드를 확인하고 두 개와 비교했지만 아무런 차이점도 발견하지 못했다. 마지막으로 quickblox의 샘플 코드 작업에 app id, api 키 및 일부 자격 증명을 대체했습니다. 그리고 샘플 앱이 내 자격 증명으로 작동하지 않는다는 것을 알았습니다. QB 계정으로 정말 중요합니까?Quickblox 그룹 채팅이 작동하지 않음 가입 나는 문제 그룹 채팅</p> <pre><code>QB.chat.muc.join(dlg.xmpp_room_jid, function(){ console.log("Joined dialog " + dlg._id + " xmpp " + dlg.xmpp_room_jid); }) </code></pre> <p>이 Quickblox의 샘플 코드에서이기 JS SDK를 quickblox 사용했다

답변

2

을 확인합니다. 필자의 경우 세션 생성 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 . "&timestamp=" . $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; 
}