开发者

Getting user data after the Facebook login

I have this page where I am doing testing

http://www.comehike.com/test_fb_connect.php

The button works fine - it lets me log in and out of Facebook, but I don't know anything about this user, so its kind of pointless.

What I need to do it pull their first_name, last_name, email, lat, lng from their FB. I had code like this before, but it just broke my site:

$message = "Apps on Facebook.com are cool!";

$feed_url = "http://www.facebook.com/dialog/feed?app_id=".$app_id."&redirect_uri=" . urlencode($canvas_page)
                . "&message=" . $message;

 if (empty($_REQUEST["post_id"])) {
    echo("<script> top.location.href='" . $feed_url . "'</script>");
 } else {
    echo ("Feed Post Id: " . $_REQUEST["post_id"]);
 }

What can I do to pull th开发者_StackOverflowe data I need for the account?

By the way, my FB login button setup looks like this:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=my_id&amp;xfbml=1">
</script><fb:login-button show-faces="false" perms="user_hometown,user_about_me,email,user_address" autologoutlink="true" width="200" max-rows="1">
</fb:login-button>

Thanks!


Once the user is authenticated you can make graph calls against the special me object:

PHP

$json = file_get_contents('https://graph.facebook.com/me');
$detailObj = json_decode($json);
var_dump($detailObj);

JavaScript

FB.api('/me', function(response) {
  alert(response.name);  //response is the basic user object
});

More on FB.api

More on available graph objects

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜