Drupal Communication

Ok heres what I would like to do.

I have a Drupal 7 website which has a Unity Webplayer running on it, how would I go about coding the webplayer to check if a user is logged in to the website or not from inside the player and display the users name and other information associated to there profile if they are logged in?

Any suggestions on this matter would be very helpful and appreciated.

This is something that is best taken up with Drupal on their forums. It’s not a Unity-specific problem.
http://drupal.org/forum

Seeing as most if not all of the work would be done within unity, most likely java in reguards to the communication I dont think the guys on the drupal forum will be very helpful unless they have experince with how unity comunicates with PHP ect and would most likely tell me to come here to ask just like you have told me to go to the drupal site resulting in an endless loop.

I will indeed leave a post on their forum anyways but for now I was hoping someone on the Unity forum might have tried this or have an Idea how it might be done as I dont think I would be the first person to attempt it.

Unity doesn’t prevent or provide any communication with the web. The calls and code for doing that communication are language-specific. Communicating with web API’s really doesn’t have anything to do with Unity.

In Unityscript, HTTP requests are usually performed via the XMLHttpRequest object with a standard API which is identical to Javascript.

Unityscript / Javascript Web Request Example:

function SendHttpGetRequest(url:string) {
  var request = new XMLHttpRequest();
  request.open("GET", url, false);
  request.send(null);
  Debug.Log(request.responseText);
}

In C# it’s done through Microsoft’s network API. It’s the WebRequest class in System.Net assembly.

C# Web Request Example:

public void SendHttpGetRequest(string url) {
  WebRequest request = new WebRequest.Create(url);
  HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
  Debug.Log(response.StatusDescription);
}

Take that code with a grain of salt. :wink:

The only thing that the Unity API actually does provide is a standard communication class (the WWW class) for downloading Unity-specific data. This makes grabbing assets from a web server coniderably easier. You can also use the WWW class for generic GET and POST requests if you want to.

I wasnt really expecting Unity have Functions specific to Drupal or any other API for that matter and I am aware of WWW class ect, I was simply asking if anyone had tried this and if so how they went about it, I thought it best to ask here first hoping that someone could save me many hours working it out as I have already spent quite a few already without much luck.

You might be right saying that the Drupal Forums might be more apropratiate but I think someone needs to have knowledge of both Unity and Drupal to understand how to make them communicate in such a way and I would expect that there are people here and on the drupal forums that know how and most likely frequent both, at least I hope so.

Thanks for your help anyways and your quick replies.