//downloading coroutine IEnumerator _LoadPost() { WWWForm form = new WWWForm(); form.AddField("tour_id", id); form.AddField("user_id", Server.user_id); UnityWebRequest www = UnityWebRequest.Post(Server.base_url + "/get_post", form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { Debug.Log(www.downloadHandler.text); PostJSON result = JsonUtility.FromJson <PostJSON>(www.downloadHandler.text); Debug.Log(JsonUtility.ToJson(result)); user_id = result.id; name.text = result.name; description.text = result.description.Substring(0, Math.Min(40, result.description.Length)); likes.text = result.likes.ToString(); comments.text = result.comments.ToString(); filled_like.SetActive(result.liked); liked = result.liked; delete_button.SetActive(user_id == Server.user_id); } }
static void Main(string[] args) { string mmm = ""; MagazineStore p = new MagazineStore(); string tk = p.GetToken(); List <string> cat = p.GetCategories(tk); foreach (string c in cat) { Console.WriteLine("cat: " + c); List <JObject> mag = p.GetMagazines(tk, c); foreach (JObject m in mag) { Console.WriteLine("mag: " + m.ToString()); JToken jmagid = m.GetValue("id"); //mmm = mmm + m.ToString(); } } mmm = ""; List <JObject> subs = p.GetSubscribers(tk); foreach (JObject sub in subs) { Console.WriteLine(sub.ToString()); JToken jid = sub.GetValue("id"); mmm = "\"" + jid.ToString() + "\"" + "," + mmm; } mmm = mmm.Remove(mmm.Length - 1); Console.WriteLine("-------------------------------"); Console.WriteLine(mmm); string r1 = PostJSON.Answer(tk, "[" + mmm + "]"); //string r2 = JsonConvert.SerializeObject(r1); PostJSON.Answer(tk, r1); Console.WriteLine("Press any key to exit!"); Console.ReadLine(); }