iphonesdk 3.0-如何在使用facebook连接PHP SDK3.0时获得用户访问令牌


iphone sdk 3.0 - how to get user access token while using facebook connect with PHP SDK3.0

Hye,我遇到了麻烦。我正在使用php-sdk3.0进行facebookconnect,并希望在我的网站上使用facebookid登录用户。我正在将当前用户的详细信息保存到我的数据库中,以后如何让用户访问令牌

试试这样的

<?php 
if ($_REQUEST['code']) {
    $app_id = "<app id>";
    $app_secret = "<secret key for your app>";
    $my_url = "<url to your app>";
    $code = $_REQUEST["code"];
    $token_url = "https://graph.facebook.com/oauth/access_token?client_id="
        . $app_id . "&redirect_uri=" . urlencode($my_url) . "&client_secret="
        . $app_secret . "&code=" . $code;
    $access_token = file_get_contents($token_url);
    $graph_url = "https://graph.facebook.com/me?" . $access_token;
    $user = json_decode(file_get_contents($graph_url));
        echo $access_token . "<br />";
        echo $user->name . "<br />";
        echo $user->id . "<br />";
}
?>