#http://devcentral.f5.com/weblogs/Joe/archive/2008/12/30/introducing-poshtweet---the-powershell-twitter-script-library.aspx

function Execute-HTTPGetCommand()
{
  param([string] $url = $null);
  if ( $url )
  {
    [System.Net.WebClient]$webClient = New-Object System.Net.WebClient
    $webClient.Credentials = Get-TwitterCredentials
    [System.IO.Stream]$stream = $webClient.OpenRead($url);
    [System.IO.StreamReader]$sr = New-Object System.IO.StreamReader -argumentList $stream;
    [string]$results = $sr.ReadToEnd();
    $results;
  }
}
function Execute-HTTPPostCommand()
{
  param([string] $url = $null, [string] $data = $null);

  if ( $url -and $data )
  {
    [System.Net.WebRequest]$webRequest = [System.Net.WebRequest]::Create($url);
    $webRequest.Credentials = Get-TwitterCredentials
    $webRequest.PreAuthenticate = $true;
    $webRequest.ContentType = "application/x-www-form-urlencoded";
    $webRequest.Method = "POST";
    $webRequest.Headers.Add("X-Twitter-Client", "PoshTweet");
    $webRequest.Headers.Add("X-Twitter-Version", "1.0");
    $webRequest.Headers.Add("X-Twitter-URL", "http://devcentral.f5.com/poshtweet");
    [byte[]]$bytes = [System.Text.Encoding]::UTF8.GetBytes($data);
    $webRequest.ContentLength = $bytes.Length;
    [System.IO.Stream]$reqStream = $webRequest.GetRequestStream();
    $reqStream.Write($bytes, 0, $bytes.Length);
    $reqStream.Flush();
    [System.Net.WebResponse]$resp = $webRequest.GetResponse();
    $rs = $resp.GetResponseStream();
    [System.IO.StreamReader]$sr = New-Object System.IO.StreamReader -argumentList $rs;
    [string]$results = $sr.ReadToEnd();
    $results;
  }
}