开发者

What is the best way to determine a clients Facebook User ID in PHP on first arrival?

The situation: a random user who may or may not be reg开发者_开发知识库istered with my site (at a different computer, lets say) signs into facebook in one tab. User then opens a new tab and goes to my website.

The problem: This is the first time that the user has ever been to my website on this computer. Therefore, there are no cookies, get variables, post variables, or anything of the sort.

Server side solution: redirect the client to facebook->getLoginStatusUrl() and then use the returned information. (If user is registered with app, call will succeed). Pros: no client code required. Cons: redirects all users who land at my site.

Client solution:Not exactly sure how exactly this would work, but something along the lines of "using js sdk to determine if logged in and if so get and store client auth token to cookie and reload page". Pros: if not logged into facebook there is no refresh, no redirect necessary. Cons: page reload, client code.

Is there a better solution? Also, anyone know more specifically how to make the client solution happen?


You get Userid and Username from Facebook when an user logged in to your site via Facebook.

You can get those via either Javascript SDK or PHP SDK.

At that time, you can query a table which is including logging in data with that userid.

If there is one then that user is not on first arrival.

If there is no results, then add that user to your table and that user is on first arrival.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜