How can I send and receive data to and from a URL, i.e. server side scripts, web services, etc?

How can I send data (eg, a string or integer value) to a server-side script or a web service through C# or Javascript in unity Web player mode.

Can you please give me some details on how to call web services. Me being new to Unity Web application, I dont know even how to call a URL and a parameter with it. So could anyone give a proper way to call Web services.

The normal way of doing this would be to use Get or Post requests via the WWW class or the WWWForm class. If you’re making a Get request with parameters added to the end of the url, you’d use code similar to this:

'GET' request in Javascript:

var url = "http://example.com/script.php?var1=value2&var2=value2";
var www : WWW = new WWW (url);

// wait for request to complete
yield www;

// and check for errors
if (www.error == null)
{
    // request completed!
} else {
    // something wrong!
    Debug.Log("WWW Error: "+ www.error);
}

'GET' request In C#

In C# this is a little more complex because of the way that you have to write out coroutines in full. In this example, the initiation of the request is done in “Start”. We then hand the WWW object to a coroutine called “WaitForRequest” which waits for the www request to complete.

using UnityEngine;

public class GetURL : MonoBehaviour {

    void Start () {
        string url = "http://example.com/script.php?var1=value2&var2=value2";
        WWW www = new WWW(url);
        StartCoroutine(WaitForRequest(www));
    }

    IEnumerator WaitForRequest(WWW www)
    {
        yield return www;

        // check for errors
        if (www.error == null)
        {
            Debug.Log("WWW Ok!: " + www.data);
        } else {
            Debug.Log("WWW Error: "+ www.error);
        }    
    }
}

And to make a Post request with the same parameters and values, it would be:

'POST' request in Javascript:

var url = "http://example.com/script.php";
var form = new WWWForm();
form.AddField( "var1", "value1" );
form.AddField( "var2", "value2");

var www = new WWW( url, form );

// wait for request to complete
yield www;

// and check for errors
if (www.error == null)
{
    // request completed!
} else {
    // something wrong!
    Debug.Log("WWW Error: "+ www.error);
}

'POST' request in C#

Again, we use exactly the same Coroutine and WWWCompleted function as in the ‘get’ example. The only difference is that we build the WWWForm object, and use that to create the WWW request before handing it to the coroutine.

using UnityEngine;

public class PostURL : MonoBehaviour {

    void Start () {

        string url = "http://example.com/script.php";

        WWWForm form = new WWWForm();
        form.AddField("var1", "value1");
        form.AddField("var2", "value2");
        WWW www = new WWW(url, form);

        StartCoroutine(WaitForRequest(www));
    }

    IEnumerator WaitForRequest(WWW www)
    {
        yield return www

        // check for errors
        if (www.error == null)
        {
            Debug.Log("WWW Ok!: " + www.data);
        } else {
            Debug.Log("WWW Error: "+ www.error);
        }    
    }    
}

I write a tutorial about http using in unity http://unity-tutorials.blogspot.com. Listing 12 - 15.
I am using subroutines for http calls to not stop UI rendering.

Watch this video to solve :Post data to a URL Unity - YouTube