Search Unity

Android url.responseHeaders["LOCATION"]; not work.

Discussion in 'Scripting' started by Gorlog, Apr 15, 2017.

  1. Gorlog

    Gorlog

    Joined:
    Jan 20, 2011
    Posts:
    201
    Hi if i thest responseHeaders on unity3d android editor works correct but on android phone is return as

    "UnityEngine.WWW"

    here is the code


    Code (CSharp):
    1.     void ShareWithUsersCallback(IAppRequestResult result)
    2.     {
    3.      
    4.  
    5.         if (result.Cancelled)
    6.         {
    7.             Debug.Log("challange Cancel");
    8.             GameObject.Find("CallBacks").GetComponent<Text>().text = "challange Cancel";
    9.         }
    10.         else if (!String.IsNullOrEmpty(result.Error))
    11.         {
    12.             Debug.Log("challange on error");
    13.             GameObject.Find("CallBacks").GetComponent<Text>().text = "challange on error";
    14.         }
    15.         else if (!String.IsNullOrEmpty(result.RawResult))
    16.         {
    17.             Debug.Log("Sucsess on challange");
    18.  
    19.  
    20.             GameObject.Find("inviteURL").GetComponent<Text>().text = "https://graph.facebook.com/" + result.ResultDictionary["to"] + "/picture?type=large";//
    21.  
    22.  
    23.             StartCoroutine(DecodeUrl());
    24.  
    25.         }
    26.     }
    27.  
    28.  
    29.  
    30.  
    31.     IEnumerator DecodeUrl()
    32.   {
    33.       WWW url = new WWW(GameObject.Find("inviteURL").GetComponent<Text>().text.ToString()); //+ "?access_token=" + FB.AccessToken);
    34.       yield return url;
    35.       GameObject.Find("inviteURL").GetComponent<Text>().text = url.ToString();
    36.       GameObject.Find("inviteURL").GetComponent<Text>().text = url.responseHeaders["LOCATION"];
    37.    
    38.       Debug.Log("Working");
    39.  
    40.       StartCoroutine(DecodeUrlNext());
    41.  
    42.  
    43. }
    44.  
    45. IEnumerator DecodeUrlNext()
    46.     {
    47.        
    48.         WWW url = new WWW(GameObject.Find("inviteURL").GetComponent<Text>().text.ToString());
    49.  
    50.         Texture2D textFb2 = new Texture2D(128, 128, TextureFormat.DXT1, false); //TextureFormat must be DXT5
    51.  
    52.         yield return url;
    53.        
    54.         GameObject.Find("inviteURL").GetComponent<Text>().text = url.ToString();
    55.        
    56.  
    57.         GameObject.Find("FacebookPicPro").GetComponent<Renderer>().material.mainTexture = textFb2;
    58.         url.LoadImageIntoTexture(textFb2);
    59.         //StartCoroutine(disableCanvas());
    60.         GameObject.Find("Canvas").SetActive(false);
    61.         Debug.Log("Working");
    62.     }
    63.  
    64.  
    65.  

    there is any way to work on android devices thx
     
  2. Gorlog

    Gorlog

    Joined:
    Jan 20, 2011
    Posts:
    201
    okey i found a solution making a php file for redirects and get redirect url from there i think unity www is not handle redirected urls
     
    Last edited: Apr 15, 2017