我正在尝试使用 Facebook-SDK 6.1.4 版列出我所有 friend 的生日
当我使用下面的代码时(即没有 FQL,它运行良好,但我无法获得生日,只有 name 和 id 值)。
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."
}
我究竟做错了什么?
最佳答案
检查是否设置了 access_token 并打印它,然后在调试器中检查它。
对于 FQL 调用,
这是基于月份内的常见字母,特别是 a、e 和 u。从那个人可以做 strpos 来匹配这些。SELECT name, birthday, email, uid FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND (strpos(lower(birthday),"a") >=0 OR strpos(lower(birthday),"e") >=0 OR strpos(lower(birthday),"u") >=0) ORDER BY birthday_date
这应该拉出所有空值,因为 null
不包含任何字母(根据空值的定义,而不是字母本身)
关于facebook - 如何使用 FQL 列出我的 friend ?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15235349/