PoshCode Archive  Artifact [ac1d3ab28e]

Artifact ac1d3ab28e876aab8ef3c736bcaed5a97225587e272152c411f2e7c44e9bb583:

  • File Get-TwitterReply.ps1 — part of check-in [de166d6658] at 2018-06-10 12:56:49 on branch trunk — Get-TwitterReply modification get all replies (user: unknown size: 1480)

# encoding: ascii
# api: powershell
# title: Get-TwitterReply
# description: Get-TwitterReply modification get all replies
# version: 0.1
# type: function
# license: CC0
# function: Get-TwitterReply
# x-poshcode-id: 1300
# x-archived: 2010-01-04T22:27:37
#
#
# 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
# usees https and gets all replies

Function Get-TwitterReply { 
 param ($username, $password)
 if ($WebClient -eq $null) {$Global:WebClient=new-object System.Net.WebClient  }
 $WebClient.Credentials = (New-Object System.Net.NetworkCredential -argumentList $username, $password)
 $page = 0
 $ret = @()
 do {  	$Page ++
    $replies = ([xml]$webClient.DownloadString("https://twitter.com/statuses/replies.xml?page=$Page")  ).statuses.status
    $ret += $replies
    Write-host  $replies.count
	} while ($replies.count -gt 0 ) # sometimes I get less than 20
 $ret
 write-host $ret.count
 # Returns the 20 most recent @replies for the authenticating user.
 #page:  Optional. Retrieves the 20 next most recent replies
 #since.  Optional.  Narrows the returned results to just those replies created after the specified HTTP-formatted date, up to 24 hours old.
 #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
}