2012-02-27 24 views
1

認真打算在這裏瘋狂....爲Android的PhoneGap Facebook的插件給了我一個oauthexception

我試圖下載Android上班的PhoneGap Facebook的插件,但它真正推動我逼瘋了(沒有雙關語intented)。

我使用的代碼從https://github.com/irnc/phonegap-plugin-facebook-connect/tree/oauth-2.0+irnc,至少我認爲我是。

我似乎有兩個問題:

  1. 在登錄下面的回調(從PG-插件-FB-CONNECT)給出了一個錯誤,因爲「FB.Auth.setAuthResponse(response.authResponse,響應。狀態);」無法找到。我是否使用了錯誤的Facebook sdk? 顯然沒有,請參閱下面

    PhoneGap.exec(function (response) { 
         console.log('PG.FB.login.success: ' + JSON.stringify(response) + ', store into localStorage ...'); 
         localStorage.setItem(key, JSON.stringify(response)); 
    
         FB.Auth.setAuthResponse(response.authResponse, response.status); 
    
         if (cb) { 
          cb(response); 
         } 
        }, null, service, 'login', ['publish_stream', 'read_stream']); 
    }, 
    
  2. 編輯當我發表意見FB.Auth.setAuthResponse(response.authResponse,response.status);聲明,我的登錄返回成功!我得到一個authresponse,並將accesstoken和狀態設置爲連接。當我嘗試執行下面的代碼(在成功回調)

    FB.api('/me/feed', 'post', { message: body }, function(response) { 
    if (!response || response.error) { 
        console.log(JSON.stringify(response.error, null, 4)); 
        alert('We are very sorry, but somthing went wrong'); 
    } else { 
        alert('Message was successfully posted to your wall!'); 
    } 
    }); 
    

它給了我一個oauthexception消息:「一個積極的訪問令牌必須用於查詢當前用戶的信息。」

我使用'read_stream,publish_stream'權限進行身份驗證。

這兩個可能是相關的,但我無法找到關於facebook api中setAuthReponse調用的任何內容。

編輯幫助顯然不是它的方式,但我一直在繼續尋求這個工作。

我從github回購所得到的facebook js sdk都使用'舊'auth方法。我已經下載了新的facebook js sdk和FB.Auth.setAuthResponse。我將代碼複製到現有的js sdk中,並將setSession的所有調用更改爲setAuthRepsonse。一切工作正常,除了當我使上面的FB.api調用時,訪問令牌似乎不會被張貼。這些更改後,錯誤仍然完全相同!

噢,我也改變了登錄回調中的支票來檢查authResponse而不是會話(它在示例中)。

幫助是更受歡迎, rinze

回答