使用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?
由于
答案 0 :(得分:0)
当我运行您的FQL select name, profile_url from user where name = 'Suresh Rajan'
时,我收到以下错误消息。
(#604)你的陈述不可索引。 WHERE子句必须包含 可转位列。这些列在表中标有* 从http://developers.facebook.com/docs/reference/fql
链接
所以看起来name属性不是你在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
快乐的编码!
答案 1 :(得分:0)
在某些特殊情况下,您只能使用列名进行查询,例如:select name, uid from user where name = 'Sergio Garcia' AND uid in (SELECT uid2 FROM friend WHERE uid1 = me())