(100) requests a parameter: an array is expected. - facebook sdk c #

string query1 = String.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 the parameter (100) of requests: an array is expected. in line dynamic imageArray = client.Query (query1, query2); What have I done wrong? The Query method accepts a string of params, so it should be fine.

+4
source share
2 answers

If you pass more than one parameter to the Query method, it will automatically use a multiple query instead of a single query.

The C # Facebook SDK automatically adds query1 and query2. you only need to enter a 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)"); 

Then you can access the fql values.

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

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

0
source

I downloaded the source. Assuming the one you are using does not have an overload that takes two lines.

  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); } 
-1
source

All Articles