2011-06-08 112 views

回答

0

嘗試這樣的事情

<?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 />"; 
} 
?> 
相關問題