示例#1
0
    IEnumerator GetGuides(string cityName)
    {
        string url       = "http://xavieriscool.web44.net/getGuides.php?" + "city=" + WWW.EscapeURL(cityName.Trim());
        WWW    getGuides = new WWW(url);

        yield return(getGuides);

        if (getGuides.error != null)
        {
            Debug.LogError("Error: " + getGuides.error);
        }
        else
        {
            string[] guides = getGuides.text.Substring(0, getGuides.text.LastIndexOf('%') - 1).Split('=');
            for (int i = 0; i < Mathf.Min(guides.Length, guidesText.Length); i++)
            {
                guidesText [i].text = guides [i];
                guidesText [i].GetComponentInChildren <Image> ().enabled = true;
            }
        }
    }
示例#2
0
 string MyEscapeURL(string url)
 {
     return(WWW.EscapeURL(url).Replace("+", "%20"));
 }
示例#3
0
 public void Add(string str)
 {
     Add(StringObject(WWW.EscapeURL(str)));
 }
示例#4
0
        public static bool InstallApp(string appFullPath, ConnectInfo connectInfo, bool waitForDone = true)
        {
            try
            {
                // Calculate the cert and dependency paths
                string fileName     = Path.GetFileName(appFullPath);
                string certFullPath = Path.ChangeExtension(appFullPath, ".cer");
                string certName     = Path.GetFileName(certFullPath);
                string depPath      = Path.GetDirectoryName(appFullPath) + @"\Dependencies\x86\";

                // Post it using the REST API
                var form = new WWWForm();

                // APPX file
                var stream = new FileStream(appFullPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                var reader = new BinaryReader(stream);
                form.AddBinaryData(fileName, reader.ReadBytes((int)reader.BaseStream.Length), fileName);
                stream.Close();

                // CERT file
                stream = new FileStream(certFullPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                reader = new BinaryReader(stream);
                form.AddBinaryData(certName, reader.ReadBytes((int)reader.BaseStream.Length), certName);
                stream.Close();

                // Dependencies
                FileInfo[] depFiles = (new DirectoryInfo(depPath)).GetFiles();
                foreach (FileInfo dep in depFiles)
                {
                    stream = new FileStream(dep.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);
                    reader = new BinaryReader(stream);
                    string depFilename = Path.GetFileName(dep.FullName);
                    form.AddBinaryData(depFilename, reader.ReadBytes((int)reader.BaseStream.Length), depFilename);
                    stream.Close();
                }

                // Credentials
                Dictionary <string, string> headers = form.headers;
                headers["Authorization"] = "Basic " + EncodeTo64(connectInfo.User + ":" + connectInfo.Password);

                // Unity places an extra quote in the content-type boundary parameter that the device portal doesn't care for, remove it
                if (headers.ContainsKey("Content-Type"))
                {
                    headers["Content-Type"] = headers["Content-Type"].Replace("\"", "");
                }

                // Query
                string query = string.Format(API_InstallQuery, connectInfo.IP);
                query += "?package=" + WWW.EscapeURL(fileName);

                var      www            = new WWW(query, form.data, headers);
                DateTime queryStartTime = DateTime.Now;

                while (!www.isDone && (DateTime.Now - queryStartTime).TotalSeconds < TimeOut)
                {
                    Thread.Sleep(10);
                }

                // Give it a short time before checking
                Thread.Sleep(250);

                // Report
                if (www.isDone)
                {
                    if (!string.IsNullOrEmpty(www.error))
                    {
                        Debug.LogError(www.error);
                    }
                    else if (!string.IsNullOrEmpty(www.text))
                    {
                        Debug.Log(JsonUtility.FromJson <Response>(www.text).Reason);
                    }
                    else
                    {
                        Debug.LogWarning("Completed with null response string");
                    }
                }

                // Wait for done (if requested)
                DateTime waitStartTime = DateTime.Now;
                while (waitForDone && (DateTime.Now - waitStartTime).TotalSeconds < MaxWaitTime)
                {
                    AppInstallStatus status = GetInstallStatus(connectInfo);
                    if (status == AppInstallStatus.InstallSuccess)
                    {
                        Debug.Log("Install Successful!");
                        break;
                    }
                    if (status == AppInstallStatus.InstallFail)
                    {
                        Debug.LogError("Install Failed!");
                        break;
                    }

                    // Wait a bit and we'll ask again
                    Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(ex.ToString());
                return(false);
            }

            return(true);
        }
示例#5
0
 public void TwitterShare()
 {
     Application.OpenURL("http://twitter.com/intent/tweet?text=" + WWW.EscapeURL("『Greeting!』友達から特別なメッセージが届いたよ!\nhttp://static.greeting.com/line/?pass_code=Mzc5Njc4NTg4\n↑このURLをタップしてGreetを受け取ろう!\n\nこのGreetが登録されているカードはこれだよ!\n\nhttp://static.greeeting.com/i/?i=379678588&k=793&p=27&f=line\n↑Greetingをまだ始めていなかったらこのURLからアプリをインストールしてね! #Greet"));
 }
示例#6
0
    public IEnumerator UploadCatalogue(string text)
    {
        //converting the xml to bytes to be ready for upload
        byte[] prizes = Encoding.UTF8.GetBytes(text);

        //generate a long random file name , to avoid duplicates and overwriting
        string fileName = "Catalogue";

        fileName = fileName.ToUpper();
        fileName = fileName + ".json";

        //if you save the generated name, you can make people be able to retrieve the uploaded file, without the needs of listings
        //just provide the level code name , and it will retrieve it just like a qrcode or something like that, please read below the method used to validate the upload,
        //that same method is used to retrieve the just uploaded file, and validate it
        //this method is similar to the one used by the popular game bike baron
        //this method saves you from the hassle of making complex server side back ends which enlists available levels
        //this way you could enlist outstanding levels just by posting the levels code on a blog or forum, this way its easier to share, without the need of user accounts or install procedures
        WWWForm form = new WWWForm();

        form.AddField("json", text);
        string url = "http://www.appatier.xyz/php/Catalogue/Upload.php?json=" + WWW.EscapeURL(text);

        Debug.Log("Json Data is :: " + text);
        //change the url to the url of the php file
        ;
        WWW w = new WWW(url, form);

        Debug.Log("www created");

        yield return(w);

        Debug.Log("after yield w" + w.text);
        if (w.error != null)
        {
            Debug.Log("Error From Server : " + w.error);
        }
        else
        {
            Debug.Log("Checking if success");
            //this part validates the upload, by waiting 5 seconds then trying to retrieve it from the web
            if (w.uploadProgress == 1 || w.isDone)
            {
                Debug.Log("Progress is done...");
                yield return(new WaitForSeconds(3));

                Debug.Log("We waited for the yield");
                //change the url to the url of the folder you want it the levels to be stored, the one you specified in the php file
                WWW w2 = new WWW("http://www.appatier.xyz/php/Catalogue/" + fileName);
                Debug.Log("Sent the request...");
                yield return(w2);

                Debug.Log("Finished Waiting");
                if (w2.error != null)
                {
                    DestroyImmediate(GameObject.Find("Uploading"));
                    //Debug.Log("error 2");
                    Debug.Log(w2.error);
                }
                else
                {
                    //then if the retrieval was successful, validate its content to ensure the level file integrity is intact
                    if (w2.text != null || w2.text != "")
                    {
                        Debug.Log(w2.text);
                        if (w2.text.Contains("itemList"))
                        {
                            //and finally announce that everything went well
                            Debug.Log("Catalogue File " + fileName + " Contents are: \n\n" + w2.text);
                            Debug.Log("Finished Uploading Level " + fileName);
                            DestroyImmediate(GameObject.Find("Uploading"));
                        }
                        else
                        {
                            Debug.Log("Level File " + fileName + " is Invalid");
                            DestroyImmediate(GameObject.Find("Uploading"));
                        }
                    }
                    else
                    {
                        Debug.Log("Level File " + fileName + " is Empty");
                        DestroyImmediate(GameObject.Find("Uploading"));
                    }
                }
            }
            else
            {
                Debug.LogError("Uploading Failed...");
                DestroyImmediate(GameObject.Find("Uploading"));
            }
        }
    }
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 protected string ConstructFetchSheetURL()
 {
     return(string.Format("{0}getSheets?spreadsheetId={1}&requestData={2}",
                          _serverUrl, _spreadsheetId, WWW.EscapeURL(_requestData)));
 }
示例#8
0
        private IEnumerator ProcessRequestQueue()
        {
            // yield AFTER we increment the connection count, so the Send() function can return immediately
            _activeConnections += 1;
#if UNITY_EDITOR
            if (!UnityEditorInternal.InternalEditorUtility.inBatchMode)
            {
                yield return(null);
            }
#else
            yield return(null);
#endif

            while (_requests.Count > 0)
            {
                Request req = _requests.Dequeue();
                if (req.Cancel)
                {
                    continue;
                }
                string url = URL;
                if (!string.IsNullOrEmpty(req.Function))
                {
                    url += req.Function;
                }

                StringBuilder args = null;
                foreach (var kp in req.Parameters)
                {
                    var key   = kp.Key;
                    var value = kp.Value;

                    if (value is string)
                    {
                        value = WWW.EscapeURL((string)value);             // escape the value
                    }
                    else if (value is byte[])
                    {
                        value = Convert.ToBase64String((byte[])value);    // convert any byte data into base64 string
                    }
                    else if (value is Int32 || value is Int64 || value is UInt32 || value is UInt64 || value is float || value is bool)
                    {
                        value = value.ToString();
                    }
                    else if (value != null)
                    {
                        Log.Warning("RESTConnector", "Unsupported parameter value type {0}", value.GetType().Name);
                    }
                    else
                    {
                        Log.Error("RESTConnector", "Parameter {0} value is null", key);
                    }

                    if (args == null)
                    {
                        args = new StringBuilder();
                    }
                    else
                    {
                        args.Append("&");                 // append separator
                    }
                    args.Append(key + "=" + value);       // append key=value
                }

                if (args != null && args.Length > 0)
                {
                    url += "?" + args.ToString();
                }

                AddHeaders(req.Headers);

                Response resp = new Response();

                DateTime startTime = DateTime.Now;
                if (!req.Delete)
                {
                    WWW www = null;
                    if (req.Forms != null)
                    {
                        if (req.Send != null)
                        {
                            Log.Warning("RESTConnector", "Do not use both Send & Form fields in a Request object.");
                        }

                        WWWForm form = new WWWForm();
                        try
                        {
                            foreach (var formData in req.Forms)
                            {
                                if (formData.Value.IsBinary)
                                {
                                    form.AddBinaryData(formData.Key, formData.Value.Contents, formData.Value.FileName, formData.Value.MimeType);
                                }
                                else if (formData.Value.BoxedObject is string)
                                {
                                    form.AddField(formData.Key, (string)formData.Value.BoxedObject);
                                }
                                else if (formData.Value.BoxedObject is int)
                                {
                                    form.AddField(formData.Key, (int)formData.Value.BoxedObject);
                                }
                                else if (formData.Value.BoxedObject != null)
                                {
                                    Log.Warning("RESTConnector", "Unsupported form field type {0}", formData.Value.BoxedObject.GetType().ToString());
                                }
                            }
                            foreach (var headerData in form.headers)
                            {
                                req.Headers[headerData.Key] = headerData.Value;
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Error("RESTConnector", "Exception when initializing WWWForm: {0}", e.ToString());
                        }
                        www = new WWW(url, form.data, req.Headers);
                    }
                    else if (req.Send == null)
                    {
                        www = new WWW(url, null, req.Headers);
                    }
                    else
                    {
                        www = new WWW(url, req.Send, req.Headers);
                    }

#if ENABLE_DEBUGGING
                    Log.Debug("RESTConnector", "URL: {0}", url);
#endif

                    // wait for the request to complete.
                    float timeout = Mathf.Max(Constants.Config.Timeout, req.Timeout);
                    while (!www.isDone)
                    {
                        if (req.Cancel)
                        {
                            break;
                        }
                        if ((DateTime.Now - startTime).TotalSeconds > timeout)
                        {
                            break;
                        }
                        if (req.OnUploadProgress != null)
                        {
                            req.OnUploadProgress(www.uploadProgress);
                        }
                        if (req.OnDownloadProgress != null)
                        {
                            req.OnDownloadProgress(www.progress);
                        }

#if UNITY_EDITOR
                        if (!UnityEditorInternal.InternalEditorUtility.inBatchMode)
                        {
                            yield return(null);
                        }
#else
                        yield return(null);
#endif
                    }

                    if (req.Cancel)
                    {
                        continue;
                    }

                    bool bError = false;
                    if (!string.IsNullOrEmpty(www.error))
                    {
                        int nErrorCode = -1;
                        int nSeperator = www.error.IndexOf(' ');
                        if (nSeperator > 0 && int.TryParse(www.error.Substring(0, nSeperator).Trim(), out nErrorCode))
                        {
                            switch (nErrorCode)
                            {
                            case 200:
                            case 201:
                                bError = false;
                                break;

                            default:
                                bError = true;
                                break;
                            }
                        }

                        if (bError)
                        {
                            Log.Error("RESTConnector", "URL: {0}, ErrorCode: {1}, Error: {2}, Response: {3}", url, nErrorCode, www.error,
                                      string.IsNullOrEmpty(www.text) ? "" : www.text);
                        }
                        else
                        {
                            Log.Warning("RESTConnector", "URL: {0}, ErrorCode: {1}, Error: {2}, Response: {3}", url, nErrorCode, www.error,
                                        string.IsNullOrEmpty(www.text) ? "" : www.text);
                        }
                    }
                    if (!www.isDone)
                    {
                        Log.Error("RESTConnector", "Request timed out for URL: {0}", url);
                        bError = true;
                    }

                    /*if (!bError && (www.bytes == null || www.bytes.Length == 0))
                     * {
                     *  Log.Warning("RESTConnector", "No data recevied for URL: {0}", url);
                     *  bError = true;
                     * }*/


                    // generate the Response object now..
                    if (!bError)
                    {
                        resp.Success = true;
                        resp.Data    = www.bytes;
                    }
                    else
                    {
                        resp.Success = false;
                        resp.Error   = string.Format("Request Error.\nURL: {0}\nError: {1}",
                                                     url, string.IsNullOrEmpty(www.error) ? "Timeout" : www.error);
                    }

                    resp.ElapsedTime = (float)(DateTime.Now - startTime).TotalSeconds;

                    // if the response is over a threshold, then log with status instead of debug
                    if (resp.ElapsedTime > LogResponseTime)
                    {
                        Log.Warning("RESTConnector", "Request {0} completed in {1} seconds.", url, resp.ElapsedTime);
                    }

                    if (req.OnResponse != null)
                    {
                        req.OnResponse(req, resp);
                    }

                    www.Dispose();
                }
                else
                {
#if ENABLE_DEBUGGING
                    Log.Debug("RESTConnector", "Delete Request URL: {0}", url);
#endif

#if UNITY_EDITOR
                    float timeout = Mathf.Max(Constants.Config.Timeout, req.Timeout);

                    DeleteRequest deleteReq = new DeleteRequest();
                    deleteReq.Send(url, req.Headers);
                    while (!deleteReq.IsComplete)
                    {
                        if (req.Cancel)
                        {
                            break;
                        }
                        if ((DateTime.Now - startTime).TotalSeconds > timeout)
                        {
                            break;
                        }
                        yield return(null);
                    }

                    if (req.Cancel)
                    {
                        continue;
                    }

                    resp.Success = deleteReq.Success;
#else
                    Log.Warning("RESTConnector", "DELETE method is supported in the editor only.");
                    resp.Success = false;
#endif
                    resp.ElapsedTime = (float)(DateTime.Now - startTime).TotalSeconds;
                    if (req.OnResponse != null)
                    {
                        req.OnResponse(req, resp);
                    }
                }
            }

            // reduce the connection count before we exit..
            _activeConnections -= 1;
            yield break;
        }
 public override string ToString()
 {
     return(string.Join("&", this.Select(a => WWW.EscapeURL(a.Key) + "=" + WWW.EscapeURL(a.Value)).ToArray()));
 }
示例#10
0
    /**
     * Submits the message to the database.
     */
    public IEnumerator submitMessage(int retrievalNr, string user, string message)
    {
        string url = ("https://wordup.devcode.nl/insert_message.php?RetrievalNr=" + retrievalNr + "&User="******"&Message=" + WWW.EscapeURL(message));

        Debug.Log(url);
        WWW webRequest = new WWW(url);

        yield return(webRequest);
    }
示例#11
0
    public static void LogScreen(string title)
    {
        title = WWW.EscapeURL(title);

        var url = "http://www.google-analytics.com/collect?v=1&ul=en-us&t=appview&sr=" + screenRes + "&an=" + WWW.EscapeURL(appName) + "&a=448166238&tid=" + propertyID + "&aid=" + bundleID + "&cid=" + WWW.EscapeURL(clientID) + "&_u=.sB&av=" + appVersion + "&_v=ma1b3&cd=" + title + "&qt=2500&z=185";

        WWW request = new WWW(url);
    }
示例#12
0
 public static string EscapeURL(string url)
 {
     return(WWW.EscapeURL(url).Replace("+", "%20"));
 }
示例#13
0
	IEnumerator TestTTS()
	{
		string url = "http://translate.google.com/translate_tts?" + string.Format("sl={0}&tl={1}&q=\"{2}\"", "en", "en",  WWW.EscapeURL("Hero"));
		Debug.Log(url);
		WWW www = new WWW(url);
		yield return www;
		if (www.error == null)
		{
			GetComponent<AudioSource>().clip = www.GetAudioClip(false, false, AudioType.MPEG);
			GetComponent<AudioSource>().Play();
		}
		else
		{
			Debug.Log(www.error);
		}
	}
示例#14
0
    IEnumerator GetProfileFromDB(string guideName)
    {
        string url        = "http://xavieriscool.web44.net/getProfile.php?" + "name=" + WWW.EscapeURL(guideName.Trim());
        WWW    getProfile = new WWW(url);

        yield return(getProfile);

        if (getProfile.error != null)
        {
            Debug.LogError("Error: " + getProfile.error);
        }
        else
        {
            string[] guides = getProfile.text.Substring(0, getProfile.text.LastIndexOf('%') - 1).Split('=');
            profileEmail.text = "Email: " + guides [0].Trim();
            profilePhone.text = "Phone #: " + guides [1].Trim();
            profileBlurb.text = guides [2].Trim();
            id = guides [3].Trim();
            string name = guideName;
            if (name.Contains("Xavier"))
            {
                FBScript.GetFBProfilPic(s[0]);
            }
            else if (name.Contains("Jimmy"))
            {
                FBScript.GetFBProfilPic(s[1]);
            }
            else if (name.Contains("Lizzy"))
            {
                FBScript.GetFBProfilPic(s[2]);
            }
            else
            {
                FBScript.GetFBProfilPic(s[3]);
            }
        }
    }
示例#15
0
    /* END OF FACEBOOK VARIABLES */

    // Twitter Share Button
    public void shareScoreOnTwitter()      // " " + Link + " " +
    {
        Application.OpenURL(TWITTER_ADDRESS + "?text=" + WWW.EscapeURL(textToDisplay) + PlayerPrefs.GetInt("myhighscore").ToString() + "&amp;lang=" + WWW.EscapeURL(TWEET_LANGUAGE));
    }
        /// <summary>
        /// Installs the target application on the target device.
        /// </summary>
        /// <param name="appFullPath"></param>
        /// <param name="targetDevice"></param>
        /// <param name="waitForDone">Should the thread wait until installation is complete?</param>
        /// <returns>True, if Installation was a success.</returns>
        public static bool InstallApp(string appFullPath, ConnectInfo targetDevice, bool waitForDone = true)
        {
            bool success = false;

            try
            {
                // Calculate the cert and dependency paths
                string fileName     = Path.GetFileName(appFullPath);
                string certFullPath = Path.ChangeExtension(appFullPath, ".cer");
                string certName     = Path.GetFileName(certFullPath);
                string depPath      = Path.GetDirectoryName(appFullPath) + @"\Dependencies\x86\";

                // Post it using the REST API
                var form = new WWWForm();

                // APPX file
                Debug.Assert(appFullPath != null);
                using (var stream = new FileStream(appFullPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (var reader = new BinaryReader(stream))
                    {
                        form.AddBinaryData(fileName, reader.ReadBytes((int)reader.BaseStream.Length), fileName);
                    }
                }

                // CERT file
                Debug.Assert(certFullPath != null);
                using (var stream = new FileStream(certFullPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    using (var reader = new BinaryReader(stream))
                    {
                        form.AddBinaryData(certName, reader.ReadBytes((int)reader.BaseStream.Length), certName);
                    }
                }

                // Dependencies
                FileInfo[] depFiles = new DirectoryInfo(depPath).GetFiles();
                foreach (FileInfo dep in depFiles)
                {
                    using (var stream = new FileStream(dep.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        using (var reader = new BinaryReader(stream))
                        {
                            string depFilename = Path.GetFileName(dep.FullName);
                            form.AddBinaryData(depFilename, reader.ReadBytes((int)reader.BaseStream.Length), depFilename);
                        }
                    }
                }

                // Query
                string query = string.Format(API_InstallQuery, FinalizeUrl(targetDevice.IP));
                query += "?package=" + WWW.EscapeURL(fileName);

                var response = WebRequestPost(query, form, GetBasicAuthHeader(targetDevice));

                if (string.IsNullOrEmpty(response))
                {
                    Debug.LogErrorFormat("Failed to install {0} on {1}.\n", fileName, targetDevice.MachineName);
                    return(false);
                }

                // Wait for done (if requested)
                DateTime waitStartTime = DateTime.Now;
                while (waitForDone && (DateTime.Now - waitStartTime).TotalSeconds < MaxWaitTime)
                {
                    EditorUtility.DisplayProgressBar("Connecting to Device Portal", "Installing...", (float)((DateTime.Now - waitStartTime).TotalSeconds / MaxWaitTime));
                    AppInstallStatus status = GetInstallStatus(targetDevice);

                    if (status == AppInstallStatus.InstallSuccess)
                    {
                        Debug.LogFormat("Successfully installed {0} on {1}.", fileName, targetDevice.MachineName);
                        success = true;
                        break;
                    }

                    if (status == AppInstallStatus.InstallFail)
                    {
                        Debug.LogErrorFormat("Failed to install {0} on {1}.\n", fileName, targetDevice.MachineName);
                        break;
                    }

                    // Wait a bit and we'll ask again
                    Thread.Sleep(1000);
                }

                EditorUtility.ClearProgressBar();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                success = false;
            }

            return(success);
        }
示例#17
0
        /**
         * Updates the FriendsLst in the background.
         * Takes a list of the Friend Ids from fitbit
         * Sets the friends in PLayerManager
         * */
        public static void updateFriendsList(List <string> friendIds)
        {
            if (friendIds.Capacity == 0)
            {
                Debug.Log("You have no friends :(");
                return;
            }
            Debug.Log("Getting Friend Stats");
            List <PlayerStats> friendsList = new List <PlayerStats>(0);
            Thread             oThread     = new Thread(new ThreadStart(() =>
            {
                Thread.Sleep(2);
                HttpWebResponse response;

                try
                {
                    //StreamWriter dataStream = new StreamWriter(request.GetRequestStream());
                    var queryParam = "?a=a";
                    foreach (string friendId in friendIds)
                    {
                        //dataStream.Write("friendId[]="+ friendId);
                        queryParam += "&friendId[]=" + WWW.EscapeURL(friendId);
                    }
                    string url  = GET_FRIENDS + WWW.EscapeURL(queryParam);
                    var request = (HttpWebRequest)WebRequest.Create(url);
                    setUpHeaders(request);
                    Debug.Log("URL: " + url);
                    ServicePointManager.ServerCertificateValidationCallback +=
                        new RemoteCertificateValidationCallback(
                            (sender, certificate, chain, policyErrors) => { return(true); });
                    response = (HttpWebResponse)request.GetResponse();

                    using (response)
                    {
                        //TODO do better error catching
                        if (response.StatusCode != HttpStatusCode.OK)
                        {
                            Debug.Log("There's been a problem trying to access the database:" +
                                      Environment.NewLine +
                                      response.StatusDescription);
                        }
                        else
                        {
                            string line        = Utilities.getStringFromResponse(response);
                            JSONObject lineObj = new JSONObject(line);

                            lineObj.GetField("friends", delegate(JSONObject idList)
                            {
                                foreach (JSONObject obj in idList.list)
                                {
                                    PlayerStats playerStats = new PlayerStats(obj);
                                    if (playerStats.id != "")
                                    {
                                        friendsList.Add(playerStats);
                                        Debug.Log("ADDING FRIEND: " + playerStats);
                                    }
                                }
                            });
                        }
                        PlayerManager.fitBitFriends = friendsList;
                    }
                }
                catch (Exception e)
                {
                    Debug.Log("Exception in updateFriendsList(): " + e);
                    return;
                }
            }));

            oThread.Start();
        }
示例#18
0
 public void Button_Twitter()
 {
     Application.OpenURL("http://www.twitter.com/intent/tweet" + "?text=" + WWW.EscapeURL(socialMessage) + WWW.EscapeURL("http://play.google.com/store/apps/details?id=com.SidejopGames.PushBoat") + WWW.EscapeURL(" #Mobile #Android #PushBoat"));
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sheetName"></param>
 /// <returns></returns>
 protected string ConstructFetchSheetURL(string sheetName)
 {
     return(string.Format("{0}getData?spreadsheetId={1}&sheetName={2}",
                          _serverUrl, _spreadsheetId, WWW.EscapeURL(sheetName)));
 }
示例#20
0
    public void Button_Facebook()
    {
        //add appid and such TEST TEST TEST
        //Application.OpenURL("http://www.facebook.com/sharer/sharer.php?u=" + WWW.EscapeURL(socialMessage));

        Application.OpenURL("http://www.facebook.com/dialog/share" + "?app_id=" + "213845043267767" + "&href=" + WWW.EscapeURL("http://play.google.com/store/apps/details?id=com.SidejopGames.PushBoat") + "&quote=" + socialMessage + WWW.EscapeURL(" #Mobile #Android #PushBoat") + "&display=popup" + "&redirect_uri=" + WWW.EscapeURL("http://www.facebook.com/"));
    }
示例#21
0
    //This is the text which you want to show
    //string textToDisplay = Forum.forumContent;

    /*END OF TWITTER VARIABLES*/

    // Use this for initialization
    public void shareScoreOnTwitter()
    {
        Application.OpenURL(TWITTER_ADDRESS + "?text=" + WWW.EscapeURL(Forum.forumContent) + "&amp;lang=" + WWW.EscapeURL(TWEET_LANGUAGE));
    }
示例#22
0
    /// <summary>
    /// Creates the web view.
    /// </summary>
    /// <returns>The web view.</returns>
    public void Init()
    {
        _loadingOverlay.SetActive(true);

        LoadingTimer.Instance.IsTimerStop(true);

        this.gameObject.AddComponent <UniWebView> ();
        _webView = this.gameObject.GetComponent <UniWebView> ();

        string url = DomainData.GetWebviewDataURL(DomainData.WEBVIEW_MAP) + AppStartLoadBalanceManager._userKey;

        // 条件しばり追加
        string querystring = "";

        if (EventManager.SearchEventManager.Instance._lat != "")
        {
            querystring += "&lat=" + EventManager.SearchEventManager.Instance._lat;
        }
        if (EventManager.SearchEventManager.Instance._lng != "")
        {
            querystring += "&lng=" + EventManager.SearchEventManager.Instance._lng;
        }
        if (EventManager.SearchEventManager.Instance._sex != "")
        {
            querystring += "&sex_cd=" + EventManager.SearchEventManager.Instance._sex;
        }
        if (EventManager.SearchEventManager.Instance._ageFrom != "")
        {
            querystring += "&age_from=" + EventManager.SearchEventManager.Instance._ageFrom;
        }
        if (EventManager.SearchEventManager.Instance._ageTo != "")
        {
            querystring += "&age_to=" + EventManager.SearchEventManager.Instance._ageTo;
        }
        if (EventManager.SearchEventManager.Instance._heightFrom != "")
        {
            querystring += "&height_from=" + EventManager.SearchEventManager.Instance._heightFrom;
        }
        if (EventManager.SearchEventManager.Instance._heightTo != "")
        {
            querystring += "&height_to=" + EventManager.SearchEventManager.Instance._heightTo;
        }
        if (EventManager.SearchEventManager.Instance._bodyType != "")
        {
            querystring += "&body_type=" + WWW.EscapeURL(EventManager.SearchEventManager.Instance._bodyType);
        }
        if (EventManager.SearchEventManager.Instance._isImage != "")
        {
            querystring += "&is_image=" + EventManager.SearchEventManager.Instance._isImage;
        }
        if (EventManager.SearchEventManager.Instance._keyword != "")
        {
            querystring += "&keyword=" + EventManager.SearchEventManager.Instance._keyword;
        }

        _webView.OnLoadComplete += OnLoadComplete;

        url += querystring;
        Debug.Log(url + " U R L ");
        _webView.url = url;


        _webView.backButtonEnable         = false;
        _webView.autoShowWhenLoadComplete = true;
        _webView.SetTransparentBackground(true);
        _webView.AddUrlScheme("profile");
        // 設定サイズを取得
        //WebviewLayout.InsetsParameter wInsets = WebviewLayout.GetInsetsWebview (0.1785f, 0.0f, 0.097f);
        WebviewLayout.InsetsParameter wInsets = WebviewLayout.GetInsetsWebview(0.19f, 0.0f, 0.2f);
        _webView.insets = new UniWebViewEdgeInsets(wInsets.top, wInsets.side, wInsets.bottom, wInsets.side);
        //_webView.SetShowSpinnerWhenLoading (true);
        _webView.OnReceivedMessage += OnReceivedMessage;
        _webView.Load();
    }
示例#23
0
    IEnumerator DownloadRoutine(string doc_id, string name)
    {
        string url = "http://132.248.16.11/unity/RutinasSandwich/" + WWW.EscapeURL(doc_id) + "/" + WWW.EscapeURL(name);

        //WWWForm form = new WWWForm();
        Debug.Log(url);
        WWW ww = new WWW(url);

        yield return(ww);

        Debug.Log("Descargando la rutina asignada.");
        if (ww.error == null)
        {
            string fullPath = pathStoreAllInfo + "\\" + name;
            File.WriteAllBytes(fullPath, ww.bytes);
            //nombreRutinaAJugar=fullPath; //esta direccion se utilizara en la escena PreJuega
            Debug.Log("Rutinaddescargadaconexito");
            ReadRutina(fullPath);
        }
        else
        {
            Debug.Log("ERROR: " + ww.error + "No hay XML en server");             //Probablemente no existe el archivo
        }
    }
示例#24
0
    public override void Start()  // Imsi
    {
        //Purchase = PurchaseType.Nstore;

        Ag.LogIntenseWord(" MenuManager    Started ..... ");
        //mGameMatchOk = false;
        Ag.SingleTry    = 0;
        Ag.CurrentScene = "MENU";

        //-----------Popup Cash Item
        int ran = AgUtil.RandomInclude(1, 999);

        //if (Ag.mySelf.MinutesAfterRegist > 1440 && ran % 5 < 5) // 100 % @ 411


        Ag.ContGameNum = 0;
        mBackDepthFlag = false;
        MailItemInit();
        InitInAppPurchaseIOSnADR();
        mFriendId = "";
        Ag.mySelf.SetCostumeToCard();
        //FriendRank ();
        mwas                   = new WasCard();
        mCard                  = new AmCard();
        mRankFriend            = new WasRank();
        BarObj                 = new List <GameObject> ();
        mTimeLooseAtStartPoint = 0f;
        Ag.LogIntenseWord(" MenuManager :: Start  .. Game Init ()  ");
        LoadMenuResources();
        SettingLocal();

        // '킥오프' 주황색 버튼
        BtnKickOff.MakeAbility(true);
//        BtnKickOff.SetObjectsWithAlt ( FindMyChild (dicMenuList ["Ui_kickoff"], "Panel_bottom/bundle_rightbtn/btn1_ready2", false), null,
//            FindMyChild (dicMenuList ["Ui_kickoff"], "Panel_bottom/bundle_rightbtn/btn1_ready", true));


        if (Ag.mGuest)
        {
            Ag.mySelf.WAS.profileURL = "";
            Ag.mySelf.WAS.KkoNick    = "No name";
            Ag.mySelf.KkoNickEncode  = "No name";
        }
        else
        {
            Ag.mySelf.WAS.profileURL  = StcPlatform.ProfileURL;
            Ag.mySelf.WAS.KkoNick     = StcPlatform.PltmNick;
            Ag.mySelf.KkoNickEncode   = WWW.EscapeURL(StcPlatform.PltmNick);
            Ag.mySelf.TeamNameEncoded = WWW.EscapeURL(Ag.mySelf.WAS.TeamName);
        }

        if (PreviewLabs.PlayerPrefs.GetBool("DidTutorial"))
        {
            AgStt.mgGameTutorial = false;
        }
        else
        {
            AgStt.mgGameTutorial = true;
        }

        #if UNITY_EDITOR
        PreviewLabs.PlayerPrefs.SetBool("DidTutorial", true);
        AgStt.mgGameTutorial = false;
        #endif

        //GitIgnoreThis.GitIgnoreTutorial ();

        addsendmessageTutorPanel();

        Ag.LogIntenseWord(" MenuManager :: Start  .. for  ");

        for (int i = 0; i < KakaoFriends.Instance.appFriends.Count; i++)
        {
            if (i == KakaoFriends.Instance.appFriends.Count - 1)
            {
                mFriendId += KakaoFriends.Instance.appFriends [i].userid;
            }
            else
            {
                mFriendId += KakaoFriends.Instance.appFriends [i].userid + ",";
            }
            Debug.Log(mFriendId);
        }

        Kick_OffInit();
        PriceSetting();
        SetNodeDelegate();



        Ag.LogIntenseWord(" MenuManager :: Start  .. Sale Item  ");

        SaleItemSetting();
        //pushSetting ();

        Ag.mViewCard.CardLeagueSpritename(Ag.mySelf.WAS.League);

        Ag.LogIntenseWord(" MenuManager :: Start  .. spriteName  " + Ag.mySelf.WAS.League + Ag.mViewCard.LeagueSpriteNameS);
        dicMenuList ["Lobby_division"].GetComponent <UISprite> ().spriteName    = Ag.mViewCard.LeagueSpriteNameS;
        dicMenuList ["Ui_team_division"].GetComponent <UISprite> ().spriteName  = Ag.mViewCard.LeagueSpriteNameS;
        dicMenuList ["MY_Label_division"].GetComponent <UISprite> ().spriteName = Ag.mViewCard.LeagueSpriteNameS;


        //   Debug.Log (GiftRewardCode()+"   gift");

        #if UNITY_ANDROID
        var skus = new string[] {
            "com.prime31.testproduct",
            "android.test.purchased",
            "com.prime31.managedproduct",
            "com.prime31.testsubscription"
        };
        GoogleIAB.queryInventory(skus);
        #endif

        Ag.mySelf.ApplyCurrentDeck();
        Ag.LogIntenseWord(" MenuManager :: Start  .. End ....   ");
        //ShowDeckEffLabel ();

        InitFriendRank();

        if (Ag.mGameStartAlready)
        {
            Btn_Fun_MatchRequire();
            PopupAfterGameEnd();
            if (Ag.mBlueItemFlag)
            {
                StartCoroutine(btn_auto_label_Priceoff());
            }
        }
        else
        {
            if (Ag.mySelf.MinutesAfterRegist > 60 && ran % 20 == 3) // 5% ...  // ran % 5 < 5) // 100 % @ 411
            {
                PopupAfterUserCash();
            }
            BannerEventAction();
//            if (!PreviewLabs.PlayerPrefs.GetBool ("FirstCharge_check")) {
//                dicMenuList ["Ui_popup"].SetActive (true);
//                dicMenuList ["first_purchase"].SetActive (true);
//            }
        }
    }
示例#25
0
 public void LINEShare()
 {
     Application.OpenURL("http://line.naver.jp/R/msg/text/?" + WWW.EscapeURL("『Greeting!』友達から特別なメッセージが届いたよ!\nhttp://static.greeting/line/?pass_code=Mzc5Njc4NTg4\n↑このURLをタップしてGreetを受け取ろう!\n\nこのGreetが登録されているカードはこれだよ!\n\nhttp://static.greeting.com/i/?i=379678588&k=793&p=27&f=line\n↑Greetingをまだ始めていなかったらこのURLからアプリをインストールしてね!", System.Text.Encoding.UTF8));
 }
        /// <inheritdoc />
        public void TranslateText(TranslateTextEventHandler eventHandler, string key, string textToTranslate, string languageFrom, string languageTo)
        {
            if (IsInitialized == false)
            {
                Debug.LogError("The translator is not initialized! Aborting process");
                return;
            }
            if (eventHandler == null)
            {
                Debug.LogError("There's no valid event handler set to translate text! Aborting process");
                return;
            }
            if (textToTranslate == string.Empty || languageFrom == string.Empty || languageTo == string.Empty)
            {
                Debug.LogError("Invalid values to translate! Aborting process");
                return;
            }

            Debug.Log("Translating key:" + key + ", from:" + languageFrom + ", to:" + languageTo);

            string     url = "http://api.microsofttranslator.com/v2/Http.svc/Translate?text=" + WWW.EscapeURL(textToTranslate) + "&from=" + languageFrom + "&to=" + languageTo;
            WebRequest translationWebRequest = HttpWebRequest.Create(url);

            translationWebRequest.Headers["Authorization"] = headerValue;


            TranslateTextData translateTextData = new TranslateTextData();

            translateTextData.dictionaryKey         = key;
            translateTextData.translationWebRequest = translationWebRequest;
            translateTextData.eventHandler          = eventHandler;

            translationWebRequest.BeginGetResponse(new AsyncCallback(ReadTranslateTextResponse), translateTextData);
        }
示例#27
0
 public static string EscapeURL(string str)
 {
     return(WWW.EscapeURL(str));
 }
示例#28
0
        public IEnumerator InitPlugin(int width, int height, string sharedfilename, string initialURL, bool enableWebRTC, bool enableGPU)
        {
            _localhostname = WWW.EscapeURL(sharedfilename);
            initialURL     = RedirectLocalhost(initialURL);
            _pollthread    = new Thread(BackgroundPollThread);
            _pollthread.Start();
            //Initialization (for now) requires a predefined path to PluginServer,
            //so change this section if you move the folder
            //Also change the path in deployment script.
            StreamingAssetPath = Application.streamingAssetsPath;
#if UNITY_EDITOR_64
            string PluginServerPath = Path.Combine(Application.dataPath, @"SimpleWebBrowser\PluginServer\x64");
#else
#if UNITY_EDITOR_32
            string PluginServerPath = Application.dataPath + @"\SimpleWebBrowser\PluginServer\x86";
#else
            //HACK
            string AssemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            //log this for error handling
            Debug.Log("Assembly path:" + AssemblyPath);

            AssemblyPath = Path.GetDirectoryName(AssemblyPath);        //Managed

            AssemblyPath = Directory.GetParent(AssemblyPath).FullName; //<project>_Data
            AssemblyPath = Directory.GetParent(AssemblyPath).FullName; //required

            string PluginServerPath = AssemblyPath + @"\PluginServer";
#endif
#endif



            Debug.Log("Starting server from:" + PluginServerPath);

            kWidth  = width;
            kHeight = height;



            _sharedFileName = sharedfilename;

            //randoms
            Guid inID = Guid.NewGuid();
            _outCommFile = inID.ToString();

            Guid outID = Guid.NewGuid();
            _inCommFile = outID.ToString();

            _initialURL   = initialURL;
            _enableWebRTC = enableWebRTC;
            _enableGPU    = enableGPU;

            if (BrowserTexture == null)
            {
                BrowserTexture = new Texture2D(kWidth, kHeight, TextureFormat.BGRA32, false);
                if (OnTextureObjectUpdated != null)
                {
                    OnTextureObjectUpdated(BrowserTexture);
                }
            }

            string args = BuildParamsString();


            _connected     = false;
            _inCommServer  = null;
            _outCommServer = null;

            var pluginpath = Path.Combine(PluginServerPath, @"SharedPluginServer.exe");
            while (!_connected)
            {
                try
                {
                    _pluginProcess = new Process {
                        StartInfo = new ProcessStartInfo {
                            WorkingDirectory = PluginServerPath,
                            FileName         = pluginpath,
                            Arguments        = args
                        }
                    };
                    _pluginProcess.Start();
                    Initialized = false;
                }
                catch (Exception ex)
                {
                    //log the file
                    Debug.Log("FAILED TO START SERVER FROM:" + PluginServerPath + @"\SharedPluginServer.exe");
                    throw;
                }
                yield return(new WaitForSeconds(1.0f));

                bool isReady = false;
                while (!isReady)
                {
                    try {
                        isReady = _pluginProcess.WaitForInputIdle(0);
                    }
                    catch (Exception e) {
                        Debug.LogException(e);
                        if (_pluginProcess.HasExited)
                        {
                            break;
                        }
                    }
                    yield return(new WaitForSeconds(0.5f));
                }
                MessageReader inserv  = null;
                MessageWriter outserv = null;
                try {
                    inserv         = MessageReader.Open(_inCommFile);
                    outserv        = MessageWriter.Open(_outCommFile);
                    _inCommServer  = inserv;
                    _outCommServer = outserv;
                    _connected     = true;
                }
                catch (Exception e) {
                    if (_inCommServer != null)
                    {
                        _inCommServer.Dispose();
                    }
                    if (_outCommServer != null)
                    {
                        _outCommServer.Dispose();
                    }
                    _pluginProcess.Dispose();
                }
            }
        }
示例#29
0
 public void AddField(string name, string val)
 {
     AddField(name, StringObject(WWW.EscapeURL(val)));
 }
示例#30
0
    IEnumerator UploadNewHighscore(string username, float score)
    {
        WWW www = new WWW(LeaderboardKey.webURL + LeaderboardKey.privateCode + "/add/" + WWW.EscapeURL(username) + "/" + score);

        yield return(www);

        if (string.IsNullOrEmpty(www.error))
        {
            Debug.Log("Upload successful");
            DownloadHighscores();
        }
        else
        {
            Debug.Log("Error uploading: " + www.error);
        }
    }