Facebook C # using multiquery results

I use multiquery to get friends out on a date. I have a query that returns data as expected, but I want to create a DataTable containing the elements from each of the queries. I have only 3 results, but there are at least a hundred in the data. I'm not sure what I'm doing wrong, except that I know that my cycle is wrong. Ironically, or not, 3 is the number of requests. I am sure that this is my foreach, but I am not sure that I should go in cycles. Please, help.

dynamic resultCheckins = fb.Get("fql", new { q = new { friends_checkins = "SELECT author_uid, coords, timestamp, page_id, message FROM checkin WHERE author_uid IN (SELECT uid2 FROM friend WHERE uid1 = me())", users = "SELECT uid, name, pic_small from user where uid IN (SELECT author_uid FROM #friends_checkins)", resultCheckins = "SELECT page_id, name, description from place where page_id IN (SELECT page_id FROM #friends_checkins)", } }); JObject resultCheckinsJson = JObject.Parse(resultCheckins.ToString()); DataTable CheckIn = new DataTable(); CheckIn.Columns.Add(new DataColumn("Friend", typeof(string))); CheckIn.Columns.Add(new DataColumn("Picture", typeof(string))); CheckIn.Columns.Add(new DataColumn("Link", typeof(string))); CheckIn.Columns.Add(new DataColumn("Place", typeof(string))); CheckIn.Columns.Add(new DataColumn("Coords", typeof(string))); CheckIn.Columns.Add(new DataColumn("When", typeof(string))); CheckIn.Columns.Add(new DataColumn("Message", typeof(string))); int thiscounter = 0; foreach (var row in resultCheckinsJson["data"].Children()) { string placename = resultCheckins.data[1].fql_result_set[thiscounter].name.ToString().Replace("\"", ""); string NavigateURL = "http://facebook.com/" + resultCheckins.data[1].fql_result_set[thiscounter].page_id.ToString().Replace("\"", ""); DataRow CheckInRow = CheckIn.NewRow(); CheckInRow["Friend"] = resultCheckins.data[2].fql_result_set[thiscounter].name; CheckInRow["Picture"] = resultCheckins.data[2].fql_result_set[thiscounter].pic_small; CheckInRow["Link"] = ResolveUrl(NavigateURL); CheckInRow["Place"] = resultCheckins.data[1].fql_result_set[thiscounter].name.ToString().Replace("\"", ""); CheckInRow["Coords"] = resultCheckins.data[0].fql_result_set[thiscounter].coords.ToString().Replace("\"", ""); DateTime dtDateTime = dtDateTime.AddSeconds(resultCheckins.data[0].fql_result_set[thiscounter].timestamp).ToLocalTime(); CheckInRow["When"] = dtDateTime.ToString(); CheckInRow["Message"] = resultCheckins.data[0].fql_result_set[thiscounter].message.ToString(); CheckIn.Rows.Add(CheckInRow); thiscounter++; } 
+4
source share
1 answer

Try changing this line:

 foreach (var row in resultCheckinsJson["data"].Children()) 

To:

foreach (dynamic line in resultCheckinsJson.data)

Then we get the following properties:

 row.name 
0
source

Source: https://habr.com/ru/post/1415245/


All Articles