1

使用 Facebook API 在 ASP.NET 中按名称搜索 FQL 不起作用。但是,这在 5 天前运行良好。最近,当我在 ASP.NET 中使用 FQL(Facebook API)按姓名查找人员时,它不起作用。

最近,Facebook 开发团队在进行了一些更改后部署了 Facebook API。

我可以得到以下 FQL 的响应:

select name, first_name, last_name from user where uid = '1730923544'

我无法得到以下 FQL 的响应(但我可以得到空字符串)

select name, pic_square, profile_url from user where name = 'Suresh Rajan'

这是我的完整代码:

public partial class _Default : System.Web.UI.Page 
{
    facebook.Components.FacebookService _fb = null;

    public _Default()
    {
        _fb = new FacebookService();
        _fb.ApplicationKey = "bfeefa69afdfe81975f0d6136ace3009";
        _fb.Secret = "9b672d682e1d8befd06382953fc2615b";
        _fb.IsDesktopApplication = false;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        infobel_FacebookMethod();        
    }

    private void infobel_FacebookMethod()
    {
        try
        {
            string s = String.Empty;

            //I cannot have response for this fql ( but getting empty string )
            //s = _fb.fql.query("select name, profile_url from user where name = 'Suresh Rajan'");

            //Here I can get response 
            s = _fb.fql.query("select name, from user where uid = '1730923544'");

            if (String.IsNullOrEmpty(str1))
                Response.Write("Empty Response");
            else
                Response.Write(str1 + " <br />");            
        }
        catch (Exception exp)
        {
            Response.Write("Message = " + exp.Message + "<br />");
            Response.Write("ToString = " + exp.ToString());
        }
    }
}

如何在 ASP.NET 中编写 FQL?

谢谢

4

2 回答 2

0

当我运行您的 FQL 时,select name, profile_url from user where name = 'Suresh Rajan'我会收到以下错误消息。

(#604) 您的语句不可索引。WHERE 子句必须包含一个可索引的列。这些列在从http://developers.facebook.com/docs/reference/fql链接的表格中标有 *

因此,名称属性似乎不是您可以在 where 子句中拥有的列。

但是,可能有另一种方法来获取您正在寻找的信息,使用图形 API 中的搜索命令(请参阅https://developers.facebook.com/docs/reference/api/

格式:https://graph.facebook.com/search?q=QUERY&type=OBJECT_TYPE

例子:https://graph.facebook.com/search?q=mark&type=user

所以让你玩这个去:https ://developers.facebook.com/tools/explorer

快乐编码!

于 2012-01-01T04:09:36.797 回答
0

只能在某些特殊情况下使用列名进行查询,如下所示:select name, uid from user where name = 'Sergio Garcia' AND uid in (SELECT uid2 FROM friend WHERE uid1 = me())

于 2012-01-01T05:57:23.863 回答