2011-11-04 20 views
0

我試圖打開一個Facebook對話框,但由於我不明白但它不起作用的原因。FB.ui失敗「錯誤消息:會話密鑰沒有相應的用戶」

這段代碼做了工作: (我清理了一點點,以便更好地說明問題)

window.fbAsyncInit = function() { 
    // get settings... 
    $app_id = Drupal.settings.gdp_general.appid; 
    $channel_url = Drupal.settings.gdp_general.channel_url; 
    // init Facebook api 
    FB.init({ 
    appId  : $app_id, // App ID 
    channelURL : $channel_url, // Channel File 
    status  : true, // check login status 
    cookie  : true, // enable cookies to allow the server to access the session 
    oauth  : true, // enable OAuth 2.0 
    xfbml  : true // parse XFBML 
    }); 
}; 

// login the user and ask for the required permissions. 
FB.login(function(response) { 
    if (response.authResponse) { 
    FB.api('/me', function(response) { 
    // do some stuff with the retrieved data 
    // .... 
    // now post something on the users wall 
    FB.api('/me/feed', 'post', { 
     caption: $title, 
     message: $description, 
     link: $url 
     }, function(response) { 
    if (!response || response.error) { 
     // error 
     } else { 
     // post was succesfull 
     $form.submit(); 
     } 
    }); 

    }); 
} else { 
    //error 
} 
}, {scope: 'email, publish_stream'}); 
}; 

這篇文章的消息給用戶牆,工作正常。 但是我認爲用戶打開一個對話框會更好,這樣他就可以看到將要發佈到牆上的內容。

但是當我改變

FB.api('/me/feed', 'post', { 

FB.ui({method: 'feed', 

它不工作了和Facebook返回一個錯誤「錯誤消息:會話密鑰有沒有相應的用戶」。

+0

如果我嘗試使用測試用戶的訪問令牌並打開一個apprequests對話框 - 同樣的錯誤(iPhone) –

回答

0

您是否使用頁面訪問令牌/以頁面登錄?在這種情況下,對話框將不起作用

+0

請解釋一下嗎?我認爲FB.login函數會提供適當的權限? – K3vin

相關問題