开发者

(100) queries parameter: array expected. - facebook SDK C#

            string query1 = Strin开发者_C百科g.Format("\"query1\":\"SELECT pid, object_id, src_big, owner FROM photo where object_id={0}\"", photoFbId);
            string query2 = String.Format("\"query2\":\"SELECT first_name, last_name FROM user where uid in (select owner from #query1)\""); 

            var client = new FacebookClient(accessToken);
            dynamic imageArray = client.Query(query1,query2);

gives (100) queries parameter: array expected. in line dynamic imageArray = client.Query(query1,query2); What have I done wrong? The Query method accepts params string so it should be fine..


If you pass more then one parameter to the Query method, it will automatically use the multi-query instead of single query.

The Facebook C# SDK automatically adds the query1 and query2. you only need to enter the query.

var fb = new FacebookClient("access_token");
dynamic result = fb.Query(
    string.Format("SELECT pid, object_id, src_big, owner FROM photo where object_id={0}", photoFbId),
    "SELECT first_name, last_name FROM user where uid in (select owner from #query1)");

You can then access the values of the fql by.

var result0 = result[0].fql_result_set;
var result1 = result[1].fql_result_set;

You can learn more about making requests using Facebook C# SDK at http://blog.prabir.me/post/Facebook-CSharp-SDK-Making-Requests.aspx


I downloaded the source. Assuming that's the one you're using, there is no overload that takes two strings.

    public virtual object Query(string fql)
    {
        Contract.Requires(!String.IsNullOrEmpty(fql));

        var parameters = new Dictionary<string, object>();
        parameters["query"] = fql;
        parameters["method"] = "fql.query";

        return Get(parameters);
    }

    public virtual object Query(params string[] fql)
    {
        Contract.Requires(fql != null);

        var queryDict = new Dictionary<string, object>();

        for (int i = 0; i < fql.Length; i++)
        {
            queryDict.Add(string.Concat("query", i), fql[i]);
        }

        var parameters = new Dictionary<string, object>();
        parameters["queries"] = queryDict;
        parameters["method"] = "fql.multiquery";

        return Get(parameters);
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜