开发者

Get Facebook `userid` or `username`

Is there an easy way to get the user's facebook userid and/or username via php that is recent. I'm beat. I'll do more research tomorrow; I've now spent over a week looking over APIs and outdated docs. I'm using the Graph API....just wondering if anyone has a shortcut, once the user proceeds from my website, logs into FB, then accepts the permission for my App.

I know there's a lot of bouncing back and forth with the authentication and token thing. I can retrieve everything but the user's id. I can even get to a final page on MY website where you enter your FB name and can make the post. I just can't figure out the user name/ ID automatically.

I've looked in the $_SESSION, $_COOKIE, $_POST and $_GET superglobals.

I know it's something easy I'm overlooking. 开发者_Go百科I'm willing to give the url out...heck I'll even create a login on my server if you want to search the PHP code.


If sb open your application on facebook into iframe, facebook will make a POST call to get your website from the specified Canvas URL by you. When doing this, it will post a "signed_request" variable and its data is some information about the user. Its happening only the first time, when facebook loads the iframe's content. You can check the $_POST['signed_request'] variable, if it has user_id, then the actual user has accepted the permissions to your application. (note the signed_request string is a encoded thing and can decoded by applications' secret) If the user isn't logged in, you can response a javascript to redirect the user to a page where he can accept permissions. more about signed request:

https://developers.facebook.com/docs/authentication/signed_request/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜