PoshCode Logo PowerShell Code Repository

Get-TwitterReply (modification of post by view diff)
embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1300"></script>download | new post

Get-TwitterReply modification get all replies

  1. # Its a modification from the version in http://blogs.technet.com/jamesone/archive/2009/02/16/how-to-drive-twitter-or-other-web-tools-with-powershell.aspx
  2. # usees https and gets all replies
  3.  
  4. Function Get-TwitterReply {
  5.  param ($username, $password)
  6.  if ($WebClient -eq $null) {$Global:WebClient=new-object System.Net.WebClient  }
  7.  $WebClient.Credentials = (New-Object System.Net.NetworkCredential -argumentList $username, $password)
  8.  $page = 0
  9.  $ret = @()
  10.  do {   $Page ++
  11.     $replies = ([xml]$webClient.DownloadString("https://twitter.com/statuses/replies.xml?page=$Page")  ).statuses.status
  12.     $ret += $replies
  13.     Write-host  $replies.count
  14.         } while ($replies.count -gt 0 ) # sometimes I get less than 20
  15.  $ret
  16.  write-host $ret.count
  17.  # Returns the 20 most recent @replies for the authenticating user.
  18.  #page:  Optional. Retrieves the 20 next most recent replies
  19.  #since.  Optional.  Narrows the returned results to just those replies created after the specified HTTP-formatted date, up to 24 hours old.
  20.  #since_id.  Optional.  Returns only statuses with an ID greater than (that is, more recent than) the specified ID.  Ex: http://twitter.com/statuses/replies.xml?since_id=12345
  21. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me