在客户端中启动多重查询会引发解析器错误

发布于 2024-10-19 17:40:15 字数 995 浏览 1 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野心澎湃 2024-10-26 17:40:15

这是 firepol 答案的替代方案,带有命名查询:

var queries = 
    new Dictionary<string, object>
    {
        { "FamDamly", "select uid from family where profile_id = me()" },
        { "FamDetails", "select uid, first_name from user where uid in #FamDamly" }
    };
client.Get(queries);

Here is an alternate to firepol's answer, with named queries:

var queries = 
    new Dictionary<string, object>
    {
        { "FamDamly", "select uid from family where profile_id = me()" },
        { "FamDetails", "select uid, first_name from user where uid in #FamDamly" }
    };
client.Get(queries);
一直在等你来 2024-10-26 17:40:15

要引用第一个查询(例如问题中的查询)进行多重查询,请执行以下操作:

//note: queries begin from 0, not from 1
string query0 = "SELECT uid2 FROM friend WHERE uid1 = me()";
string query1 = "SELECT uid1, uid2 FROM friend WHERE uid1 IN (SELECT uid2 FROM #query0) AND uid2 IN (SELECT uid2 FROM #query0)";

dynamic result = fb.Query(query0, query1);

为了回答这个问题,我从这里得到了启发(必须弄清楚查询从 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:

//note: queries begin from 0, not from 1
string query0 = "SELECT uid2 FROM friend WHERE uid1 = me()";
string query1 = "SELECT uid1, uid2 FROM friend WHERE uid1 IN (SELECT uid2 FROM #query0) AND uid2 IN (SELECT uid2 FROM #query0)";

dynamic result = fb.Query(query0, query1);

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文