PSTwitterAPI - a PowerShell module for the Twitter API
PowerShell
PSTwitterAPI
Features
API Helpers cmdlets to mimic +125 Twitter API enpoints.
You can set multiple ApiKey/Token.
Handles rate limit for you, and rotate through your ApiKeys.
Handles loops to request more data. Available with:
Get-TwitterSearch_Tweets
Get-TwitterStatuses_HomeTimeline
Get-TwitterStatuses_MentionsTimeline
Get-TwitterStatuses_UserTimeline
Installation
Install-Module PSTwitterAPI
Getting started
Import-Module PSTwitterAPI
$OAuthSettings=@{
ApiKey=$env:ApiKeyApiSecret=$env:ApiSecretAccessToken=$env:AccessTokenAccessTokenSecret=$env:AccessTokenSecret
}
Set-TwitterOAuthSettings@OAuthSettings# Use one of the API Helpers provided:$TwitterUser=Get-TwitterUsers_Lookup-screen_name 'mkellerman'# Send tweet to your timeline:Send-TwitterStatuses_Update-status "Hello World!! @mkellerman #PSTwitterAPI"# Send DM to a user:$Event=Send-TwitterDirectMessages_EventsNew-recipient_id $TwitterUser.Id-text "Hello @$($TwitterUser.screen_name)!! #PSTwitterAPI"# Get the tweets you would see on your timeline:$TwitterStatuses=Get-TwitterStatuses_HomeTimeline-count 100# Show last 5 home timeline tweetsGet-TwitterStatuses_HomeTimeline-count 5|Select-Object-Property text -ExpandProperty user |Select-Object name, text |Format-List# Get tweets from someone elses timeline (what they tweeted):$TwitterStatuses=Get-TwitterStatuses_UserTimeline-screen_name 'mkellerman'-count 400# Search for tweets:$Tweets=Get-TwitterSearch_Tweets-q '#powershell'-count 400