2012-02-22 148 views

回答

0

根據最新的C#SDK文檔,他們建議使用getLoginStatus()或login()方法使用Facebook JavaScript SDK獲取令牌。然後通過AJAX將該訪問令牌通過https發送回服務器,以便C#代碼在會話(或其他數據存儲)中進行處理和存儲。

0
<?php 
$app_id = "YOUR_APP_ID"; 
$app_secret = "YOUR_APP_SECRET"; 
$post_login_url = "http://YOUR_URL/THIS_FILE.php"; 

//Obtain the access_token with publish_stream permission 
if(empty($_REQUEST['code'])){ 
    $dialog_url= "http://www.facebook.com/dialog/oauth?" 
. "client_id=" . $app_id 
. "&redirect_uri=" . urlencode($post_login_url) 
. "&scope=publish_stream"; 
echo("<script>top.location.href='" . $dialog_url 
. "'</script>"); 
} 
else { 
$code = $_REQUEST['code']; 
$token_url="https://graph.facebook.com/oauth/access_token?" 
. "client_id=" . $app_id 
. "&redirect_uri=" . urlencode($post_login_url) 
. "&client_secret=" . $app_secret 
. "&code=" . $code; 
$response = file_get_contents($token_url); 
    $params = null; 
    parse_str($response, $params); 
    $access_token = $params['access_token']; 

    setcookie("FBCode", $access_token); 
} 
?> 

是我的工作解決方案。 我將我的access_token保存在cookie中,並將其解析到我的Silverlight 5瀏覽器內應用程序中。