转自这里
//尝试GET方式通信
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
private string url = "http://map.exceedu.com/iface/login.php?opt=logcheck";
// Use this for initialization
IEnumerator Start () {
WWW getData = new WWW(url);
yield return getData;
if(getData.error!= null)
{
Debug.Log(getData.error);
}
else
{
Debug.Log(getData.text);
}
}
// Update is called once per frame
void Update () {
//Debug.Log("Update...");
}
}
//利用POST方式通信
public classJsonTest : MonoBehaviour {
private string
url = "http://map.exceedu.com/iface/login.php?opt=logcheck";
// Use this for initialization
IEnumerator Start () {
WWWForm form = newWWWForm();
form.AddField("userid","ABC");
form.AddField("pwd","***");
WWW getData = newWWW(url,form);
yield return getData;
if(getData.error!= null)
{
Debug.Log(getData.error);
}
else
{
Debug.Log(getData.text);
}
}
}