在客户端启动多重查询会抛出解析器错误 [英] Starting multiquery in client throws parser error

查看:142
本文介绍了在客户端启动多重查询会抛出解析器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c#SDK中遇到以下问题:当我尝试在我的桌面应用程序中运行以下字符串(搜索对共同的朋友的ID)的多重查询时,我得到一个解析器错误:

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);

解析器错误:位置0的意外{

如果我将它粘贴到
http://developers.facebook.com/docs/reference/rest/fql.multiquery/
但不在
http://developers.facebook.com/docs/reference/rest/fql .query /
所以问题是我需要启动它作为多查询而不是查询 - 现在我想问的是:

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:

是否可以使用SDK的Facebook.FacebookClient.Query 函数以某种方式处理多查询,还是要写一个这样做的函数?据了解,我唯一需要改变的地方就是连接到的地址。如果是这样,可以在下一个SDK版本中添加吗?

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?

推荐答案

第一个查询,例如问题中的一个,请执行以下操作:

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);

为了回答这个问题,我从这里得到启发(必须弄清楚查询从0开始): 如何在C#SDK中使用fql.multiquery

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

享受!

这篇关于在客户端启动多重查询会抛出解析器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆