I
I
ImPuuLsE2014-12-19 17:05:48
Yii
ImPuuLsE, 2014-12-19 17:05:48

Unity3D + PHP interaction?

Good evening, I don’t understand why it gives out 400 Bad Request .... with this code in the unit:

#pragma strict
var id = "";
function Connect(){

  var form = new WWWForm();
    form.AddField('id' , 'id');
    
    var download = new WWW('http://test/user', form);
    yield download;
    
    if(download.error){
    	print('error downloading:' + download.error);
    	return;
    }else{
    	Debug.Log(download.text);
    }
}
function OnGUI(){
  //Создаём текстовое поле для id
  id = GUI.TextField(new Rect(Screen.width/2-100, Screen.height/2-100, 200, 20), id, 12);

  if (GUI.Button(new Rect(Screen.width/2-100, Screen.height/2-25, 200, 20), "Connect"))
  {
    Connect();
  }
}

echo $_REQUEST['id'];
server side on yii2... test/user - controller user and in it action index this code...

Answer the question

In order to leave comments, you need to log in

4 answer(s)
H
HeBonpoc, 2014-12-19
@ImPuuLsE

It seems to me that the matter is that you do not have a host in the URl. It would be host1.dev/test then the action index in the TestController would be called back.

K
Konstantin Kitmanov, 2014-12-20
@k12th

https://ru.wikipedia.org/wiki/%D0%A1%D0%BF%D0%B8%D...
Check what new WWW generates there (I think you can sniff traffic using Fiddler2).

D
Daniil Basmanov, 2014-12-23
@BasmanovDaniil

Where is your id used?

D
Dallos, 2015-10-26
@Dallos

Guys, who will tell? there is a file written in unity3d
there is an html file with it in the kit, if you run the html file in the browser, then everything is displayed normally. But I have a site in php, and I want to link it to one of the tabs on the site (there is a mini-game), who can tell me how to do it? I've already broken my whole head, whatever one may say, the unity player shows a white screen and error messages .... How to fix it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question