我正在嘗試使用Facebook-SDK版本6.1.4列出我所有的朋友的生日當我使用下面的代碼時(即沒有FQL,它運行良好,但我無法得到生日,只是名稱和ID值)。如何使用FQL列出我的朋友?
var client = new FacebookClient(access_token);
dynamic me = client.Get(myusername);
client.IsSecureConnection = true;
friendListData = client.Get("/" + me.id + "/friends?fields=name,id");
JObject job = JObject.Parse(friendListData.ToString());
所以我試圖用FQL代碼,它會引發異常。
var client = new FacebookClient(access_token);
client.IsSecureConnection = true;
dynamic me = client.Get(myusername);
//var id = me.id;
Facebook.JsonObject friendListData = new Facebook.JsonObject();
try
{
friendListData = (Facebook.JsonObject)client.Get("fql",
new
{
q = new
{
name = "SELECT name, birthday, email, uid FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' ORDER BY birthday_date"
}
});
}
catch (FacebookOAuthException facebookAuth)
{
//"(OAuthException - #102) A user access token is required to request this resource."
}
我在做什麼錯?
_is_您的訪問令牌的_user_訪問令牌? (順便說一句,你也可以通過「普通」API查詢獲得生日,但不一定是FQL。) – CBroe 2013-03-05 22:37:51
我已經使用了下面的URL來生成access_token。它是一個APP訪問令牌。 https://graph.facebook.com/oauth/access_token? client_id = YOUR_APP_ID &client_secret = YOUR_APP_SECRET &grant_type = client_credentials – abhi 2013-03-06 13:43:54
CBroe,我認爲您已經指出了我的正確方向。我需要使用的令牌應該是用戶訪問令牌,而不是應用訪問令牌。 – abhi 2013-03-06 14:23:01