我想獲得當前Facebook用戶的Silverlight遊戲,不是在.NET頁面中託管,只是一個HTML頁面。 silverlight遊戲將使用他們的id作爲提交高分的憑證。獲取當前的Facebook用戶ID
我不希望他們使用我的應用程序登錄Facebook。我希望他們在我的應用程序之外登錄Facebook。然後我的應用程序使用Graph API的.Get(「我」)進行檢查。但是,.Get(「我」)總是返回null。即使facebookClient具有應用程序訪問令牌或appid +祕密。
我正在使用C#facebook sdk版本5.4.1.0(用於SL4支持)。
這是我嘗試做使用的appid +祕密:
var app = new Facebook.FacebookClient(appId, appSecret);
app.GetCompleted += new EventHandler<Facebook.FacebookApiEventArgs>(app_GetCompleted);
app.GetAsync("me");
}
void app_GetCompleted(object sender, Facebook.FacebookApiEventArgs e)
{
//the value of me below is always null
var me = e.GetResultData() as IDictionary<string, object>;
string id = (string)me["id"];
}
根據其他網站的應用程序訪問令牌應該是綽綽有餘,以獲得當前的Facebook用戶的ID:
- Facebook C# SDK Get Current User
- http://developers.facebook.com/docs/reference/api/user/
- Facebook C# sdk - Does the FacebookApp.Get("me") access to Facebook or just to cookie?
- What is the best way to get the UserId of the current user
- Facebook C# SDK and Access Token
我在做什麼錯誤/誤解獲取當前的Facebook用戶ID?
編輯:調試信息
Fiddler2結果404:
"message": "(#803) Some of the aliases you requested do not exist: clientaccesspolicy.xml",
"type": "OAuthException",
"code": 803
Fiddler2導致400:
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500
FacebookApiEventArgs e.Error.Message:
Value cannot be null. Parameter name: stream
FacebookApiEventArgs e.Error.StackTrace:
at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean leaveOpen)
at System.IO.StreamReader..ctor(Stream stream)
at Facebook.FacebookClient.ProcessResponse(HttpHelper httpHelper, Stream responseStream, Type resultType, String& responseStr, Exception& exception, Boolean& cancelled)
謝謝。看起來需要身份驗證才能獲取在.Get(「我」) – ShawnFeatherly
Your Welcome :)中找到的任何公共數據:) –