如何通过q​​uickblox(PHP)登录facebook

时间:2014-08-14 16:23:13

标签: quickblox

我已阅读本节http://quickblox.com/developers/Social_Networks_Integration_Manual

但我不知道该怎么办。如果有人知道请帮助我:)。

我试过hybridauth我已经连接facebook(我的API)hybridauth返回给我用户信息。我在quickblox中创建用户随机密码和facebook电子邮件并模拟登录但这很糟糕因为quickblox这种方式不回到我的标记,如果我想编辑profil我不能....

if(isset($ _GET [“login”])){

try{

        $hybridauth = new Hybrid_Auth( $config );

        $adapter = $hybridauth->authenticate( "facebook" );

        $user_profile = $adapter->getUserProfile();
    }
    catch( Exception $e ){
        die( "<b>got an error!</b> " . $e->getMessage() ); 
    }

    $token = $adapter->getAccessToken();
    //$token['access_token'];
     $nonce = rand();
    $timestamp = time(); 
    $signature_string = "application_id=".APPLICATION_ID."&auth_key=".AUTH_KEY."&nonce=".$nonce."&timestamp=".$timestamp;

        $signature = hash_hmac('sha1', $signature_string , AUTH_SECRET);
        // Build post body
        //$post_body = "application_id=" . APPLICATION_ID . "&auth_key=".AUTH_KEY."&timestamp=".$timestamp."&nonce=".$nonce."&signature=".$signature."&user[email]=" . $user_profile->email . "&provider=facebook&scope=friends_status,read_mailbox,photo_upload&keys[token]=".$token['access_token'];
        $post_body = http_build_query(array(
                        'application_id' => APPLICATION_ID,
                        'auth_key' => AUTH_KEY,
                        'timestamp' => $timestamp,
                        'nonce' => $nonce,
                        'signature' => $signature
                        ));

        $post_body = "application_id=" . APPLICATION_ID . "&auth_key=" . AUTH_KEY . "&timestamp=" . $timestamp . "&nonce=" . $nonce . "&signature=" . $signature."&user[login]=&user[email]=&user[password]=&provider=facebook&scope=friends_status,read_mailbox,photo_upload&keys[token]=".$token['access_token']."&keys[secret]=";
        $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

        $response = curl_exec($curl);
        dump($response);
        if ($response) {
                return $response . "\n";
        } else {
                $error = curl_error($curl). '(' .curl_errno($curl). ')';
                return $error . "\n";
        }

这不起作用......这是可怜的,他们没有例子:O

1 个答案:

答案 0 :(得分:0)

您应该添加&#39; provider = facebook&#39;到 post_body signature_string

此后 - QuickBlox将返回带有Facebook登录对话框的HTML页面,您应将其呈现给最终用户