Using HTTPS GET in iOS Apps built using C# Unity

public IEnumerator UpdatePlayerDataScoreAndGetRank() {

 string url = "https://www.example.com?abc=2&xyz=23";
 url =  System.Uri.EscapeUriString(url); // Very important

 string dataString = "Some data";
 byte[] byteData = System.Text.Encoding.ASCII.GetBytes(dataString.ToCharArray());

 // Set headers
 Dictionary<string,string> headers = new Dictionary<string, string>();
 headers.Add("Content-Type", "application/json");
 headers.Add("X-Custom-Header", "value");

 WWW wwwReq = new WWW(url, byteData, headers);

 yield return wwwReq;

 if (wwwReq.error == null)
 {
   Debug.Log("DEBUG:Returned Data: " + wwwReq.data);
 }
 else
 {
   Debug.Log("ERROR: " + wwwReq.error);
 }
}

Leave a Reply

Your email address will not be published. Required fields are marked *