Hey guys Here is the Simple Login Script With Api
Login.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Login : MonoBehaviour {
public InputField Username;
public InputField Password;
private string LoginAPI="http://YourApiLink"; //Change link with your LoginAPI.
public void LoginClick()
{
WWWForm form = new WWWForm ();
//Change username/password with your tabel parameter;
form.AddField ("username",Username.text);
form.AddField ("password", Password.text);
WWW w = new WWW (LoginAPI,form);
StartCoroutine (LoginFunc(w));
}
IEnumerator LoginFunc(WWW w)
{
yield return w;
if (w.error == null)
{
Debug.Log (w.text);
}
else
{
Debug.Log ("ERROR: " + w.error + "\n");
}
}
}
Login.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Login : MonoBehaviour {
public InputField Username;
public InputField Password;
private string LoginAPI="http://YourApiLink"; //Change link with your LoginAPI.
public void LoginClick()
{
WWWForm form = new WWWForm ();
//Change username/password with your tabel parameter;
form.AddField ("username",Username.text);
form.AddField ("password", Password.text);
WWW w = new WWW (LoginAPI,form);
StartCoroutine (LoginFunc(w));
}
IEnumerator LoginFunc(WWW w)
{
yield return w;
if (w.error == null)
{
Debug.Log (w.text);
}
else
{
Debug.Log ("ERROR: " + w.error + "\n");
}
}
}
.. Be Happy . :) :)
No comments:
Post a Comment