2009-12-17 212 views
2

我的要求是更新我的網站的成員身份,我也在考慮顯示他們的朋友照片和他們上次的狀態更新。Facebook的Facebook狀態更新

我已經看過所有的文檔,不能決定哪些適合我的需要。 RESTful API,JavaScript API,FQL,XFBML,FBML,FBJS? whcin一個最好?或最好的方法?

它應該是,當他們第一次進入頁面時,除了登錄選項外,什麼也沒有。當他們點擊它時,會彈出一個彈出窗口,當他們被授權時,我們會顯示一個文本區域以發佈更新。在這裏,我想向朋友們展示他們的圖片

當他們回來後,他們應該馬上發帖,絕不要再次登錄。

有人可以幫助我的代碼?我不指望你寫所有的東西,把朋友的照片和他們上次更新到PHP數組中會很好。

非常感謝

+0

做我的回答有幫助嗎? – Ahmy 2009-12-23 09:26:26

回答

1

如果妳需要更新保存在數據庫烏爾所以U將使用Facebook的API,以檢查用戶登錄,並得到他的數據用戶的數據。我在facebook上有一個ifram應用程序,我正在使用C#代碼(asp.net應用程序),當用戶請求應用程序時,我認證他已登錄到Facebook並檢查他是否已經存在於我的數據庫中?如果不是這樣,我得到他的信息(通過使用Facebook API),並添加用戶在我的數據庫中,每次他訪問應用程序我更新他的信息。

對於他的朋友,我得到了用戶朋友的所有Facebook ID,然後循環這些ID並獲得每個ID的圖片。 下載Facebook開發人員工具包,使您能夠與Facebook通信並使用Facebook API獲取用戶信息。

希望是將幫助ü

訪問Facebook中我的應用程序和u會看到這些功能在以下鏈接: http://apps.facebook.com/hanggame/

獲取會話密鑰:

protected void Page_Load(object sender, EventArgs e) 
    { 
     //Facebook code for integration with facebook users: 
     _fbService.ApplicationKey = "Application Key"; 
     _fbService.Secret = "Secret Key"; 
     _fbService.IsDesktopApplication = false; 
     string sessionKey = (string)Session["Facebook_session_key"]; 
     if (Session["Facebook_userId"] != null) 
      userId = (long)Session["Facebook_userId"]; 

    // When the user uses the Facebook login page, the redirect back here will will have the auth_token in the query params 
    string authToken = Request.QueryString["auth_token"]; 
    if (!String.IsNullOrEmpty(sessionKey)) 
    { 
     _fbService.SessionKey = sessionKey; 
     _fbService.uid = userId; 
    } 
    else if (!String.IsNullOrEmpty(authToken)) 
    { 
     _fbService.CreateSession(authToken); 
     Session["Facebook_session_key"] = _fbService.SessionKey; 
     Session["Facebook_userId"] = _fbService.uid; 
     Session["Facebook_session_expires"] = _fbService.SessionExpires; 
    } 
    else 
    { 
     Response.Redirect(@"http://www.Facebook.com/login.php?api_key=" + _fbService.ApplicationKey + @"&v=1.0"); 
    } 
    userId = _fbService.uid; 
    //End of Facebook code  
} 
+0

謝謝,但你如何保存他的信息。,我如何獲得無限的會話密鑰? – chris 2009-12-17 11:08:18

+0

看看編輯後的迴應將包括我如何得到會話密鑰 – Ahmy 2009-12-17 11:15:27

+0

太棒了!這個代碼是否有PHP版本? – chris 2009-12-17 11:38:21