title: Unity GET/POST Wrapper
body: <p>This is a Unity3d in C# question. The goal is to create an object such that I can pass in a URL and receive data via <code>GET</code>, an object that I would create the would be a wrapper for the WWW logic. I would also like a 'POST' object too, where I could supply a url and a 'Dictionary' of key-value pairs as the post arguements. Sooo... we ultimately would like something like this:</p>
  
  <pre><code>get_data = GET.request("http://www.someurl.com/somefile.php?somevariable=somevalue");
  </code></pre>
  
  <p>AND</p>
  
  <pre><code>post_data = POST.request("http://www.someurl.com/somefile.php", post)
  // Where post is a Dictionary of key-value pairs of my post arguments. 
  </code></pre>
  
  <p>To try and accomplish this, I use the <code>WWW</code> object. Now, in order to give the <code>WWW</code> object time to download, we need to have this happening inside a <code>MonoBehaviour</code> object and <code>yield</code> the results. So I got this, which works:</p>
  
  <pre><code>public class main : MonoBehavior
  {
      IEnumerator Start()
      {
          WWW www = new WWW("http://www.someurl.com/blah.php?action=awesome_stuff"); 
          yield return www;
          Debug.Log(www.text);
      }
  }
  </code></pre>
  
  <p>What I really want is this:</p>
  
  <pre><code>public class main : MonoBehavior
  {
      IEnumerator Start()
      {
          GET request = new GET("http://www.someurl.com/blah.php?action=awesome_stuff"); 
          Debug.Log(request.get_data()); // Where get_data() returns the data (which will be text) from the request.   
      }
  }
  </code></pre>
  
  <p>Now I have the main script attached to the single <code>GameObject</code> in the hierarchy (called root). Do I need to have the <code>GET</code> script attached to the root <code>GameObject</code> as well? Can I do that dynamically from <code>main</code>?</p>
  
  <p>Ultimately, I need a solution that allows me to easily send <code>GET</code> and <code>POST</code> requests.</p>
  
  <p>Cheers!</p>