在客户端中启动多重查询会引发解析器错误
我在 C# SDK 中遇到以下问题:当我尝试使用以下字符串在桌面应用程序中运行多重查询(搜索共同朋友的 ID 对)时,出现解析器错误:
string strCommonFriendsQuery = "{
\"user_friends\":\"SELECT uid2 FROM friend WHERE uid1 = me()\",
\"mutual_friends\":\"SELECT uid1, uid2 FROM friend WHERE uid1 IN (SELECT uid2 FROM #user_friends) AND uid2 IN (SELECT uid2 FROM #user_friends)\"
}";
fb.Query(strCommonFriendsQuery);
解析器错误:位置出现意外的“{” 0.
如果我将相同的字符串(引号前没有转义序列)粘贴到 http://developers.facebook.com/docs/reference/rest/fql。多查询/ 但不在 http://developers.facebook.com/docs/reference/rest/fql。查询/ 所以问题是我需要将其作为多查询而不是查询启动 - 现在我想问的是:
是否可以使用 Facebook.FacebookClient.Query 以某种方式处理多查询 /em> SDK 的功能还是我必须编写一个可以做到这一点的函数?据我了解,我唯一需要更改的是它连接到的地址。如果有的话,可以在下一个SDK版本中添加吗?
I have a following problem in c# SDK: when I try to run multiquery in my desktop application with following string (searching for pairs of IDs of mutual friends) I get a parser error:
string strCommonFriendsQuery = "{
\"user_friends\":\"SELECT uid2 FROM friend WHERE uid1 = me()\",
\"mutual_friends\":\"SELECT uid1, uid2 FROM friend WHERE uid1 IN (SELECT uid2 FROM #user_friends) AND uid2 IN (SELECT uid2 FROM #user_friends)\"
}";
fb.Query(strCommonFriendsQuery);
Parser error: unexpected '{' at position 0.
The same string (without the escape sequences before quotation marks) works if I paste it to
http://developers.facebook.com/docs/reference/rest/fql.multiquery/
but not in
http://developers.facebook.com/docs/reference/rest/fql.query/
so the problem is that I need to launch it as multiquery and not as a query - now what I would like to ask is:
Is it possible to somehow process multi-query using the Facebook.FacebookClient.Query function of the SDK or do I have to write a function which would do that? As I understand the only thing I would need to change is the address to which it connects to. If so, could it be added in the next SDK version?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是 firepol 答案的替代方案,带有命名查询:
Here is an alternate to firepol's answer, with named queries:
要引用第一个查询(例如问题中的查询)进行多重查询,请执行以下操作:
为了回答这个问题,我从这里得到了启发(必须弄清楚查询从 0 开始): 如何将 fql.multiquery 与 C# SDK 结合使用
尽情享受!
To do a multiquery with a reference to the first query, such as the one in the question, do as follows:
To answer this, I got inspired from here (had to figure out that queries start from 0): How to use fql.multiquery with C# SDK
Enjoy!