我的fb連接web服務器如何認證通過fb ios sdk登錄的用戶?我有一個使用Facebook連接的網站。在這裏面,我使用的應用程序祕密通過由facebook的通過facebook的Python庫的JavaScript SDK創建的cookie來驗證用戶:fb ios sdk會話與現有的fb連接網站一起使用
def get_user_from_cookie(cookies, app_id, app_secret):
"""Parses the cookie set by the official Facebook JavaScript SDK.
cookies should be a dictionary-like object mapping cookie names to
cookie values.
If the user is logged in via Facebook, we return a dictionary with the
keys "uid" and "access_token". The former is the user's Facebook ID,
and the latter can be used to make authenticated requests to the Graph API.
If the user is not logged in, we return None.
Download the official Facebook JavaScript SDK at
http://github.com/facebook/connect-js/. Read more about Facebook
authentication at http://developers.facebook.com/docs/authentication/.
"""
cookie = cookies.get("fbs_" + app_id, "")
if not cookie: return None
args = dict((k, v[-1]) for k, v in cgi.parse_qs(cookie.strip('"')).items())
payload = "".join(k + "=" + args[k] for k in sorted(args.keys())
if k != "sig")
sig = hashlib.md5(payload + app_secret).hexdigest()
expires = int(args["expires"])
if sig == args.get("sig") and (expires == 0 or time.time() < expires):
return args
else:
return None
現在,我不知道如何通過誰登錄用戶連接iphone到我的網站。我只是將訪問令牌發送到我的網絡服務器,並根據訪問令牌調用圖表(只是繞過上述功能)?如果是這樣,那麼上述功能提供的所有驗證又如何呢?
@ronin,thx但我已經可以通過ios登錄並請求圖形數據。我的問題是我如何使用我的現有Facebook連接網站的會話。我想通過iphone登錄,進入網絡服務器,並從存儲在我的數據庫中的用戶帳戶抓取數據。如果我將訪問令牌發送到我的網絡服務器,除了訪問令牌是否需要其他信息以確保有效? – prostock 2011-05-11 16:13:48
@David我認爲(但我不確定)存儲在您的Web服務器中的訪問令牌是否足夠連接。 – TheRonin 2011-05-12 09:10:22