IEnumerator UploadNewHighscore(string username, int score) { UnityWebRequest WWW = UnityWebRequest.Get($"{webURL}{privateCode}/add/{UnityWebRequest.EscapeURL(username)}/{score}"); yield return(WWW.SendWebRequest()); if (!(WWW.isNetworkError || WWW.isHttpError)) { //print("Upload Successful"); //DownloadHighscores(); } else { Debug.LogWarning("Error uploading: " + WWW.error); } }
IEnumerator UploadNewHighscore(string username, int score) { UnityWebRequest www = new UnityWebRequest(webURL + privateCode + "/add/" + UnityWebRequest.EscapeURL(username) + "/" + score); yield return(www); if (string.IsNullOrEmpty(www.error)) { Debug.Log("Upload Successful"); DownloadHighscores(); } else { Debug.Log("Error uploading: " + www.error); } }
void PrepareAuthenticationRequest(IAsyncResult asyncResult) { string requestDetails = string.Format("grant_type=client_credentials&client_id={0}&client_secret={1}&scope=http://api.microsofttranslator.com", UnityWebRequest.EscapeURL(clientID), UnityWebRequest.EscapeURL(clientSecret)); HttpWebRequest request = (HttpWebRequest)asyncResult.AsyncState; //now that we have the working request, write the request details into it byte[] bytes = System.Text.Encoding.UTF8.GetBytes(requestDetails); using (Stream postStream = request.EndGetRequestStream(asyncResult)) { postStream.Write(bytes, 0, bytes.Length); } request.BeginGetResponse(new AsyncCallback(ReadAuthenticationResponse), request); }
string GetEncodedUsernames() { StringBuilder sb = new StringBuilder(UnityWebRequest.EscapeURL(playerInvite1.text)); if (playersDropdown.value > 0) { sb.Append(","); sb.Append(UnityWebRequest.EscapeURL(playerInvite2.text)); } if (playersDropdown.value > 1) { sb.Append(","); sb.Append(UnityWebRequest.EscapeURL(playerInvite3.text)); } return(sb.ToString()); }
public static void SendEmail(string email, string subject = null, string body = null) { string mailToUrl = "mailto:" + email; if (string.IsNullOrEmpty(subject) == false) { mailToUrl += "?subject=" + UnityWebRequest.EscapeURL(subject).Replace("+", "%20"); } if (string.IsNullOrEmpty(body) == false) { mailToUrl += "?body=" + UnityWebRequest.EscapeURL(body).Replace("+", "%20"); } Application.OpenURL(mailToUrl); }
static void OnLogReceived(string condition, string stackTrace, LogType type) { if (type != LogType.Exception) { return; } string content = UnityWebRequest.EscapeURL(Application.version + ": " + condition + "\n\n" + stackTrace); int hashContent = content.GetHashCode(); if (sentContents.Add(hashContent)) { var request = UnityWebRequest.Get(baseURL + content); request.SendWebRequest(); } }
/// <summary> /// Track transaction for e-commerce, in-app purchases. /// </summary> /// <param name="transactionId">Transaction ID, will be truncated up to 100 symbols.</param> /// <param name="productName">Product name.</param> /// <param name="sku">Product code.</param> /// <param name="price">Product price.</param> /// <param name="currency">ISO currency code, 3 letters. USD by default</param> public void TrackTransaction(string transactionId, string productName, string sku, decimal price, string currency = "USD") { transactionId = (transactionId.Length <= 100) ? transactionId : transactionId.Substring(0, 100); EnqueueRequest(string.Format("t=transaction&ti={0}&tr={1}&cu={2}&ts=0&tt=0", UnityWebRequest.EscapeURL(transactionId), price, UnityWebRequest.EscapeURL(currency) )); EnqueueRequest(string.Format("t=item&ti={0}&in={1}&ic={2}&ip={3}&iq=1&cu={4}", UnityWebRequest.EscapeURL(transactionId), UnityWebRequest.EscapeURL(productName), UnityWebRequest.EscapeURL(sku), price, UnityWebRequest.EscapeURL(currency) )); }
public void PushButtonExample() { var sequence = DOTween.Sequence(); sequence.Append( buttonExample.transform.DOScale(0.8f, 0.1f) ); sequence.Append( buttonExample.transform.DOScale(1.0f, 0.1f) .OnComplete(() => { string str = spell; string escName = UnityWebRequest.EscapeURL(spell); Application.OpenURL("https://ejje.weblio.jp/sentence/content/" + escName); }) ); }
public static string GetOriginalDataString(Dictionary <string, string> data) { string formData = ""; if (data != null && data.Count != 0) { foreach (string k in data.Keys) { formData += k + "=" + UnityWebRequest.EscapeURL(data[k]) + "&"; } } formData = formData.Substring(0, formData.Length - 1); return(formData); }
public void SendEmail() { string body = "\n\n----" + "\nVersion: " + Application.version + "\nSystem: " + SystemInfo.operatingSystem + "\nPlateform: " + SystemInfo.deviceModel + "\nLanguage: " + Application.systemLanguage; body = UnityWebRequest.EscapeURL(body).Replace("+", "%20"); subject = subject.Replace(" ", "%20"); string emailToSend = "mailto:" + myEmail + "?subject=" + subject + "&body=" + body; Debug.Log("Send Email: " + emailToSend); Application.OpenURL(emailToSend); }
public static void UploadScore(string name, int value) { var webRequest = new UnityWebRequest(WEB_URL + PRIVATE_CODE + "/add/" + UnityWebRequest.EscapeURL(name) + "/" + value); webRequest.SendWebRequest(); while (!webRequest.isDone && string.IsNullOrEmpty(webRequest.error)) { print(webRequest.downloadProgress); } if (!string.IsNullOrEmpty(webRequest.error)) { Debug.Log("Downloading Error: " + webRequest.error); } }
/// <summary> /// Return a Poly search URL representing a ListLikedAssetsRequest. /// </summary> private static string MakeSearchUrl(PolyListLikedAssetsRequest listLikedAssetsRequest) { StringBuilder sb = new StringBuilder(); sb.Append(BASE_URL) .Append("/v1/users/me/likedassets") .AppendFormat("?key={0}", PolyMainInternal.Instance.apiKey); sb.AppendFormat("&order_by={0}", UnityWebRequest.EscapeURL(ORDER_BY[listLikedAssetsRequest.orderBy])); sb.AppendFormat("&page_size={0}", listLikedAssetsRequest.pageSize); if (listLikedAssetsRequest.pageToken != null) { sb.AppendFormat("&page_token={0}", UnityWebRequest.EscapeURL(listLikedAssetsRequest.pageToken)); } return(sb.ToString()); }
public override string ToString() { if (parameters.Count == 0) { return(""); } StringBuilder sb = new StringBuilder("?"); foreach (KeyValuePair <string, string> param in parameters) { string key = UnityWebRequest.EscapeURL(param.Key); string value = UnityWebRequest.EscapeURL(param.Value); sb.Append(key + "=" + value + "&"); } sb.Remove(sb.Length - 1, 1); return(sb.ToString()); }
private static BlobField CreateBlobValue(BlobCollection collection, string name, object value) { if (value == null) { return(new BlobField(name, Functional.None)); } else if (IsValueType(value.GetType())) { string stringValue = UnityWebRequest.EscapeURL(value.ToString()); return(new BlobField(name, stringValue)); } else { int referenceIndex = TrackObject(collection, value); return(new BlobField(name, referenceIndex.ToString())); } }
IEnumerator UploadNewHighscore(Score newScore) { UnityWebRequest www = UnityWebRequest.Get(webURL + privateCode[((int)newScore.difficulty) - 1] + "/add/" + UnityWebRequest.EscapeURL(newScore.username) + "/" + newScore.round); Debug.Log(UnityWebRequest.EscapeURL(newScore.username) + "/" + ScoreToInt(newScore)); yield return(www.SendWebRequest()); if (string.IsNullOrEmpty(www.error)) { print("Upload Succesful"); DownloadHighScores(); } else { print("Error Uploading: " + www.error); } }
IEnumerator SetRating(Product product, int rate) { yield return(new WaitForEndOfFrame()); List <IMultipartFormSection> formData = new List <IMultipartFormSection>(); formData.Add(new MultipartFormDataSection("user_id", Global.m_user.id.ToString())); formData.Add(new MultipartFormDataSection("product_id", product.product_id.ToString())); formData.Add(new MultipartFormDataSection("title", UnityWebRequest.EscapeURL(product.title))); formData.Add(new MultipartFormDataSection("description", UnityWebRequest.EscapeURL(product.description))); formData.Add(new MultipartFormDataSection("price", UnityWebRequest.EscapeURL(product.price))); formData.Add(new MultipartFormDataSection("image", UnityWebRequest.EscapeURL(product.image))); formData.Add(new MultipartFormDataSection("url", UnityWebRequest.EscapeURL(product.url.ToString()))); formData.Add(new MultipartFormDataSection("market_id", product.market_id.ToString())); formData.Add(new MultipartFormDataSection("rate", rate.ToString())); string requestURL = Global.DOMAIN + "/API/SetRating.aspx"; UnityWebRequest www = UnityWebRequest.Post(requestURL, formData); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { mm.isQuit = true; mm.ShowAlertPopup("Please confirm internet."); yield break; } string resultData = www.downloadHandler.text; if (string.IsNullOrEmpty(resultData)) { mm.ShowAlertPopup("Server api error!"); yield break; } JsonData json = JsonMapper.ToObject(resultData); string response = json["success"].ToString(); if (response != "1") { string resText = json["responseText"].ToString(); mm.ShowAlertPopup(resText); yield break; } }
/** * Returns the dialogue's XML data */ public string GetData() { string xml = ""; //xml += "<dialogueEntry>"; xml += "<characterName>" + UnityWebRequest.EscapeURL(characterName) + "</characterName>"; xml += "<charColor>" + charColor + "</charColor>"; xml += "<dialogueText>" + UnityWebRequest.EscapeURL(dialogue) + "</dialogueText>"; /*xml += "<children>"; * foreach (DialogueEntryScript d in children) { * xml += d.GetData (); * } * xml += "</children>";*/ //xml += "</dialogueEntry>"; return(xml); }
private IEnumerator CARoutine(string email, string username, string password, AlertController ac) { string escapedEmail = UnityWebRequest.EscapeURL(email); string escapedUsername = UnityWebRequest.EscapeURL(username); string escapedpassword = UnityWebRequest.EscapeURL(password); string phpURL = baseURL + "email=" + escapedEmail + "&username="******"&password="******"There was an error with UnityWebRequest"); ac.CreateAlert("Account Creation Failed", "Could not connect to server"); } else if (uwrCreateAccount.downloadHandler.text == "Invalid email address") { ac.CreateAlert("Account Creation Failed", "Email address is invalid!"); } else if (uwrCreateAccount.downloadHandler.text == "Email already exists") { ac.CreateAlert("Account Creation Failed", "Email in use already!"); } else if (uwrCreateAccount.downloadHandler.text == "Username already exists") { ac.CreateAlert("Account Creation Failed", "Username in use already!"); } else if (uwrCreateAccount.downloadHandler.text == "MySQL failed to execute") { ac.CreateAlert("Account Creation Failed", "Could not connect to server"); } while (true) { if (uwrCreateAccount.isDone) { done = true; //Debug.Log("Done"); Destroy(this); break; } } }
/// <summary> /// Fetches the lyrics of the given song asynchronously and, if they're found, /// calls the given callback with the result afterwards. /// </summary> public static IEnumerator GetLyrics(string song, string artist, Action <Subtitle[]> callback) { // Perform request string qTrack = UnityWebRequest.EscapeURL(song); string qArtist = UnityWebRequest.EscapeURL(artist); string url = $"https://apic-desktop.musixmatch.com/ws/1.1/macro.subtitles.get?format=json&q_track={qTrack}&q_artist={qArtist}&user_language=en&userblob_id=aG9va2VkIG9uIGEgZmVlbGluZ19ibHVlIHN3ZWRlXzE3Mg&subtitle_format=mxm&app_id=web-desktop-app-v1.0&usertoken=180220daeb2405592f296c4aea0f6d15e90e08222b559182bacf92"; UnityWebRequest req = UnityWebRequest.Get(url); req.SetRequestHeader("Cookie", "x-mxm-token-guid=cd25ed55-85ea-445b-83cd-c4b173e20ce7"); yield return(req.SendWebRequest()); if (req.isNetworkError || req.isHttpError) { Debug.Log(req.error); } else { // Request done, process result try { JSONNode res = JSON.Parse(req.downloadHandler.text); JSONNode subtitleObject = res["message"]["body"]["macro_calls"]["track.subtitles.get"]["message"]["body"]["subtitle_list"].AsArray[0]["subtitle"]; JSONArray subtitlesArray = JSON.Parse(subtitleObject["subtitle_body"].Value).AsArray; // No need to sort subtitles here, it should already be done. Subtitle[] subtitles = new Subtitle[subtitlesArray.Count]; for (int i = 0; i < subtitles.Length; i++) { subtitles[i] = new Subtitle(subtitlesArray[i]); } // Subtitles found and parsed, do something with them. callback(subtitles); } catch (Exception e) { Debug.LogException(e); } } req.Dispose(); }
IEnumerator DownloadHighscoresFromDatabase(string username) { string url = webUrl + publicCode + "/pipe-get/" + UnityWebRequest.EscapeURL(username); UnityWebRequest webRequest = UnityWebRequest.Get(url); yield return(webRequest.SendWebRequest()); if (string.IsNullOrEmpty(webRequest.error)) { FormatHighscores(webRequest.downloadHandler.text); highscoresDisplay.OnHighscoresDownloaded(highscoresList); } else { print("Error downloading: " + webRequest.error); } }
IEnumerator UploadNewHighScore(string username, int score) { string url = webUrl + privateCode + "/add/" + UnityWebRequest.EscapeURL(username) + "/" + score; UnityWebRequest webRequest = UnityWebRequest.Get(url); yield return(webRequest.SendWebRequest()); if (string.IsNullOrEmpty(webRequest.error)) { print("Upload successful"); DownloadHighscores(username); } else { print("Error uploading: " + webRequest.error); } }
private IEnumerator UploadNewHighscore(string userName, int score) { userName = userName.ToUpper(); using (var www = UnityWebRequest.Get(webURL + privateCode + "/add/" + UnityWebRequest.EscapeURL(userName) + "/" + score)) { yield return(www.SendWebRequest()); if (string.IsNullOrEmpty(www.error)) { OnNewHighscoreUploaded(userName, score); } else { Debug.Log("Error uploading: " + www.error); } } }
public IEnumerator UploadNewHighScore(string username, int score) { UnityWebRequest www = new UnityWebRequest(webURL + privateCode + "/add/" + UnityWebRequest.EscapeURL(username) + "/" + score); yield return(www.SendWebRequest()); if (string.IsNullOrEmpty(www.error)) { print("High score uploaded successfully :)"); } else { print("Error uploading high score: " + www.error); } DownloadHighScores(); }
private IEnumerator GetAudio(string audioText, int idx) { loadingFlag = true; loadingObj.SetActive(true); loadingImg.fillAmount = 0f; string url = GetPermisson.GetServerAddress + "/AIQQ/TTS.php?text=" + UnityWebRequest.EscapeURL(audioText); UnityWebRequest uwr = UnityWebRequest.Get(url); uwr.SendWebRequest(); while (true) { loadingImg.fillAmount = uwr.downloadProgress; if (uwr.isDone) { break; } yield return(new WaitForEndOfFrame()); } if (uwr.isHttpError || uwr.isNetworkError) { GlobalUIManager.guim.CreateNewDialogTie("音频获取失败~"); } else { try { AudioClip ac = WavUtility.ToAudioClip(uwr.downloadHandler.data, 0, audioText); allDownloadAudio.Add(idx, ac); PlayAudio(); loadingObj.SetActive(false); } catch { GlobalUIManager.guim.CreateNewDialogTie("音频获取失败~请重试~"); loadingObj.SetActive(false); } } loadingFlag = false; }
protected override IEnumerator ExecuteImpl(Gs2Session gs2Session) { UnityWebRequest.method = UnityWebRequest.kHttpVerbGET; var url = Gs2RestSession.EndpointHost .Replace("{service}", "lock") .Replace("{region}", gs2Session.Region.DisplayName()) + "/{namespaceName}/user/me/mutex"; url = url.Replace("{namespaceName}", !string.IsNullOrEmpty(_request.namespaceName) ? _request.namespaceName.ToString() : "null"); var queryStrings = new List <string> (); if (_request.contextStack != null) { queryStrings.Add(string.Format("{0}={1}", "contextStack", UnityWebRequest.EscapeURL(_request.contextStack))); } if (_request.pageToken != null) { queryStrings.Add(string.Format("{0}={1}", "pageToken", UnityWebRequest.EscapeURL(_request.pageToken))); } if (_request.limit != null) { queryStrings.Add(string.Format("{0}={1}", "limit", _request.limit)); } url += "?" + string.Join("&", queryStrings.ToArray()); UnityWebRequest.url = url; if (_request.requestId != null) { UnityWebRequest.SetRequestHeader("X-GS2-REQUEST-ID", _request.requestId); } if (_request.accessToken != null) { UnityWebRequest.SetRequestHeader("X-GS2-ACCESS-TOKEN", _request.accessToken); } if (_request.duplicationAvoider != null) { UnityWebRequest.SetRequestHeader("X-GS2-DUPLICATION-AVOIDER", _request.duplicationAvoider); } return(Send((Gs2RestSession)gs2Session)); }
/// <summary> /// Get a specific model by it's ID. /// </summary> /// <param name="successCallback">The success callback.</param> /// <param name="failCallback">The fail callback.</param> /// <param name="model_id"></param> /// <returns></returns> public bool GetModel(SuccessCallback <TranslationModel> successCallback, FailCallback failCallback, string model_id, Dictionary <string, object> customData = null) { if (successCallback == null) { throw new ArgumentNullException("successCallback"); } if (failCallback == null) { throw new ArgumentNullException("failCallback"); } if (string.IsNullOrEmpty(model_id)) { throw new ArgumentNullException("model_id"); } RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v3/models/"); if (connector == null) { return(false); } GetModelReq req = new GetModelReq(); req.Parameters["version"] = VersionDate; req.SuccessCallback = successCallback; req.FailCallback = failCallback; req.HttpMethod = UnityWebRequest.kHttpVerbGET; req.DisableSslVerification = DisableSslVerification; req.CustomData = customData == null ? new Dictionary <string, object>() : customData; if (req.CustomData.ContainsKey(Constants.String.CUSTOM_REQUEST_HEADERS)) { foreach (KeyValuePair <string, string> kvp in req.CustomData[Constants.String.CUSTOM_REQUEST_HEADERS] as Dictionary <string, string> ) { req.Headers.Add(kvp.Key, kvp.Value); } } req.Function = UnityWebRequest.EscapeURL(model_id); req.OnResponse = GetModelResponse; req.Headers["X-IBMCloud-SDK-Analytics"] = "service_name=language_translator;service_version=v3;operation_id=GetModel"; return(connector.Send(req)); }
/** * Send a highscore for the given game to the server. * Returns the position on the scoreboard (1-based). */ static IEnumerator SendHighscore(string game, string player, int score, System.Action <int> onScore) { using (var request = UnityWebRequest.Post("https://scores.tmbe.me/score" + "?game=" + UnityWebRequest.EscapeURL(game) + "&player=" + UnityWebRequest.EscapeURL(player) + "&score=" + UnityWebRequest.EscapeURL(score.ToString()), "")) { yield return(request.SendWebRequest()); if (request.responseCode != 200) { Debug.Log("Sending highscore failed: " + request.responseCode); onScore(-1); } else { onScore(JsonUtility.FromJson <_Position>(request.downloadHandler.text).position); } } }
private static string _makeParamUrl(string url, Dictionary <string, object> parameter) { string result = url; foreach (KeyValuePair <string, object> pair in parameter) { //result += pair.Key + "=" + NCMBUtility._encodeString ((string)pair.Value) + "&"; //**Encoding が必要 #if UNITY_2017_3_OR_NEWER result += pair.Key + "=" + UnityWebRequest.EscapeURL((string)pair.Value) + "&"; //**Encoding が必要 #else result += pair.Key + "=" + WWW.EscapeURL((string)pair.Value) + "&"; //**Encoding が必要 #endif } if (parameter.Count > 0) { result = result.Remove(result.Length - 1); } return(result); }
// remember to use StartCoroutine when calling this function! IEnumerator PostScores(string name, int score) { //This connects to a server side php script that will add the name and score to a MySQL DB. // Supply it with a string representing the players name and the players score. string hash = Md5Sum(name + score + secretKey); string post_url = addScoreURL + "name=" + UnityWebRequest.EscapeURL(name) + "&score=" + score + "&hash=" + hash; using (UnityWebRequest webRequest = UnityWebRequest.Get(post_url)) { // Request and wait for the desired page. yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(highscoreURL + ": Error: " + webRequest.error); } } }
void Start() { int stageIdx = SceneTransition.LastStageIndex(); float time = stageIdx != -1 ? scoreHolder.Get().Time : 69.865f; string actualTweetText = tweetText .Replace ( "[score]", time.ToTimeString() ) .Replace ( "[draft]", (stageIdx + 1).ToString() ); url = "https://twitter.com/intent/tweet?text=" + UnityWebRequest.EscapeURL(actualTweetText); }