amitdante

Monkeymessenger

Feb 15th, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.Networking;
  6.  
  7.  
  8. public class EmailPassword : MonoBehaviour {
  9.     public InputField UserNameInput;
  10.     public InputField PasswordInput;
  11.     public InputField nameField;
  12.     public Button SignupButton;
  13.     public Button LoginButton;
  14.     public Text debug;
  15.     public PersistantScript ps;
  16.  
  17.  
  18.     //WWWForm form;
  19.     string _url;
  20.     string _user, _pass;
  21.     WWWForm form;
  22.     WWW download;
  23.  
  24.     void Start()
  25.     {
  26.  
  27.         _url = "https://api.3monkey.games/GOHW2E";
  28.         _user = "testuser";
  29.         _pass = "password";
  30.     }
  31.  
  32.     public void Login()
  33.     {
  34.         form = new WWWForm();
  35.         form.AddField("request", "login");
  36.         form.AddField("user", _user);
  37.         form.AddField("pass", _pass);
  38.         StartCoroutine("SubmitForm", form);
  39.     }
  40.  
  41.     void GetUser(int id)
  42.     {
  43.         form = new WWWForm();
  44.         form.AddField("request", "getUser");
  45.         form.AddField("uid", id);
  46.         StartCoroutine("SubmitForm", form);
  47.     }
  48.  
  49.     IEnumerator SubmitForm(WWWForm wwwForm)
  50.     {
  51.         download = new WWW(_url, wwwForm);
  52.         yield return download;
  53.         if (!string.IsNullOrEmpty(download.error))
  54.         {
  55.             print("Error downloading: " + download.error);
  56.         }
  57.         else
  58.         {
  59.             Debug.Log("Result: " + download.text);
  60.         }
  61.     }
  62. }
Add Comment
Please, Sign In to add comment