4

我正在尝试使用 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."
        }

我究竟做错了什么?

4

2 回答 2

3

检查是否正在设置 access_token 并打印它,然后在调试器中检查它。

对于 FQL 调用,

这是基于月份内的常见字母,特别是 aeu。从那里可以做 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不包含任何字母的空值(根据空值的定义,而不是字母本身)

于 2013-03-06T00:08:40.760 回答
0

使用 Windows PowerShell 和http://facebookpsmodule.codeplex.com很容易做到这一点:

import-module facebook $FB_DefaultExtendedPermissions += "friends_birthday" New-FBConnection Get-FBFriend -Fields name,birthday | 选择姓名,生日

我应该将“friends_birthday”添加到默认权限列表中......

于 2013-03-06T18:07:10.367 回答