public void LoadData(string board, string category) { string url = "https://api.pinterest.com/v1/boards/" + board + "/pins/?access_token=Ab1rhweqeChC5tmKgfILFrE6t-TYFNwv7w_soZhELMu2AwBCWQAAAAA&fields=id,note,image"; int total_pins = CountPinsBoard(board); for (int i = 0; i <= (total_pins / 25); i++) { CallApi call = new CallApi(); var json = call.Get(url); if (json != null) { JObject pinObj = new JObject(JObject.Parse(json)); var pins = pinObj["data"]; if (!IsNullOrEmpty(pins)) { Parse_Data(pins, category); } var next = pinObj["page"]["next"]; if (!IsNullOrEmpty(next)) { url = next.ToString(); } else { break; } } } }
private int CountPinsBoard(string board) { int count = 0; string url = "https://api.pinterest.com/v3/pidgets/boards/" + board + "/pins/"; CallApi call = new CallApi(); var json = call.Get(url); if (json != null) { JObject jsonObj = new JObject(JObject.Parse(json)); var jsonBoard = jsonObj["data"]["board"]; if (!IsNullOrEmpty(jsonBoard)) { count = Int32.Parse(jsonBoard["pin_count"].ToString()); } } return(count); }