Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Serialization;
- using Proyecto26;
- using UnityEditor;
- using UnityEngine.Networking;
- using System.Text;
- using TMPro;
- using SimpleJSON;
- public class APIRequest
- {
- // string basicRequestPage = "****";
- string basicAPI_Key = "****";
- // Start is called before the first frame update
- string outputs;
- public string basicRequest(int requestTyp)
- {
- auth test1 = new auth();
- test1.key = basicAPI_Key;
- switch (requestTyp)
- {
- case 0:
- test1.request = "deckList";
- break;
- case 1:
- test1.request = "card";
- break;
- }
- string output = JsonConvert.SerializeObject(test1);
- byte[] outputToServer = Encoding.ASCII.GetBytes(output); ;
- //Debug.Log(output);
- RestClient.Request(new RequestHelper
- {
- Uri = basicRequestPage,
- Method = "POST",
- Timeout = 10,
- //EnableDebug = true,
- ParseResponseBody = false, //Don't encode and parse downloaded data as JSONe
- BodyRaw = outputToServer
- }).Then(response =>
- {
- // EditorUtility.DisplayDialog("Status", response.Text, "Ok");
- var rest = response.Text;
- //Debug.Log(rest);
- outputs = rest.ToString();
- //EditorUtility.DisplayDialog("Status", outputs, "Ok");
- return outputs;
- }).Catch(err =>
- {
- var error = err as RequestException;
- EditorUtility.DisplayDialog("Error Response", error.Response + "", "Ok");
- }
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment