我试图使用Facebook-SDK版本6.1.4列出我朋友的所有生日 当我使用下面的代码时(没有FQL,它运行良好,但我无法获得生日,只有名称和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."
}
我做错了什么?
答案 0 :(得分:3)
检查是否正在设置access_token并将其打印出来,然后在调试器中进行检查。
对于FQL调用,
这是基于几个月内的常用字母,特别是 a , e 和 u 。从那个可以做strouts匹配这些。
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
不包含任何字母(根据null的定义,而不是字母本身)
答案 1 :(得分:0)
使用Windows PowerShell和http://facebookpsmodule.codeplex.com非常简单:
import-module facebook $ FB_DefaultExtendedPermissions + =“friends_birthday” 新FBConnection Get-FBFriend -Fields名称,生日|选择姓名,生日
我应该将“friends_birthday”添加到默认权限列表中......