2011-12-21 79 views
0

嗨即時通訊使用非官方fb Coldfusion SDK我不得不將它從CFscript轉換爲常規功能,因爲我仍然在CF7上。 一切似乎工作,但我不知道爲什麼當試圖查找cookie登錄在服務器端沒有找到。它在Chorme上似乎很好,但FF,IE和Opera都有同樣的問題。無法從服務器端檢索Facebook access_token,SDK加載速度太慢?

在index.cfm上,我有一個fb:登錄按鈕,當按下時,您將獲得登錄屏幕,一旦登錄成功,index.cfm refreshs將運行我的FacebookApp方法,但在從服務器端讀取時爲access_token返回一個空值。這是因爲在服務器端,我嘗試從cookie獲取信息,但cookie尚未創建。我也輸出了access_token的值,但它返回爲空白。當我大約一秒鐘後按下F5時,現在我的輸出中會看到我的access_token的值。同時,如果我使用js alert在getLoginStatus中顯示access_token,我可以看到該值。

香港專業教育學院讀一些地方舊的瀏覽器在SDK加載緩慢使用channelURL PARAM,其中香港專業教育學院完成,但IM仍然得到與上述相同的結果。

任何建議我可以做什麼?我嘗試添加js超時來減慢getLoginStatus的速度,以便有時間閱讀cookie,但沒有任何快樂。請幫忙。

頁面頂部的我有這個

<!doctype html PUBLIC "-//W3C//Dtd html 4.0 Transitional//EN"> 
<html xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"> 

身體標記之後,我有以下

<div id="fb-root"></div> 

      <script> 
       window.fbAsyncInit = function() { 
       FB.init({ 
        appId : 'xxxxxxxxxxxxxxxx', 
        cookie : true, // enable cookies to allow the server to access the session 
        oauth : true, // OAuth 2.0 
        status : true, // check login status 
        xfbml : true, // parse XFBML 
        channelUrl: document.location.protocol + './/www.sitename.com/fbchannel.html' //custom channel 
       }); 

       // whenever the user logs in or logs out, we refresh the page 
       FB.Event.subscribe('auth.login', function(response) { 
        window.location.reload(); 
        alert('login'); 
       }); 

       FB.Event.subscribe('auth.logout', function(response) { 
        window.location.reload(); 
        //alert('logout'); 
       }); 

       FB.getLoginStatus(function(response) { 
        if (response.status == 'connected') { 
        // the user is logged in and connected to your 
        // app, and response.authResponse supplies 
        // the user's ID, a valid access token, a signed 
        // request, and the time the access token 
        // and signed request each expire 
        var uid = response.authResponse.userID; 
        var accessToken = response.authResponse.accessToken; 

        //alert('end'); 
        // alert('login url called '+unescape(window.location.pathname)); 
        // whenever the user logs in we refresh the page 

        //alert(accessToken); 

        } else if (response.status == 'not_authorized') { 
        // the user is logged in to Facebook, 
        //but not connected to the app 
        } else { 
        // the user isn't even logged in to Facebook. 
        } 
       }); 

       }; 

       (function() { 
       var e = document.createElement('script'); 
       e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
       e.async = true; 
       document.getElementById('fb-root').appendChild(e); 
       }()); 
      </script> 
東西下面

某處遠高於我有我的按鈕

<fb:login-button scope="publish_stream,email" autologoutlink="true">Connect with FB</fb:login-button> 

回答

0

在花費DAYS之後,試圖找出我遇到的問題this及其m我的一天,問題解決了!感謝chwk。