SHARE
TWEET

Untitled

a guest Apr 21st, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [HideInInspector]
  2. public string topPlayer = PlayerPrefs.GetString("TopPlayer");
  3.  
  4. public void OnInputClicked(InputClickedEventData eventData)
  5. {
  6.     //UnityWebRequest request = UnityWebRequest.Post("https://hipchat.getconnected.it/v2/room/91/message", formData);
  7.  
  8.     StartCoroutine(dani());
  9.  
  10. }
  11.  
  12. IEnumerator dani()
  13. {
  14.     //string message = "{ "message": "dani2"}";
  15.     string message = "{ "message": "topPlayer"}";
  16.     UnityWebRequest request = UnityWebRequest.Post("https://hipchat.getconnected.it/xxx", message);
  17.     request.SetRequestHeader("authorization", "Bearer xxx");
  18.     request.SetRequestHeader("content-type", "application/json");
  19.     byte[] data = System.Text.Encoding.UTF8.GetBytes(message);
  20.     UploadHandlerRaw upHandler = new UploadHandlerRaw(data);
  21.     upHandler.contentType = "application/json";
  22.     request.uploadHandler = upHandler;
  23.  
  24.  
  25.     yield return request.Send();
  26.  
  27.     if (request.isError)
  28.     {
  29.         Debug.Log(request.error);
  30.     }
  31.     else
  32.     {
  33.         Debug.Log("Form upload complete!");
  34.     }
  35. }
  36.    
  37. string message = string.Format("{ "message": "{0}"}",topPlayer);
RAW Paste Data
Top