1

How would I use powershell to consume, at least in part, or for a short duration, the twitter stream (as twitter4j sample)?

Step 3: Consume the data as it’s delivered

Once the connection is established, the stream sends new Tweets through the open connection as they happen, and your client app should read the data off the line as it is received. Your client app will need to recognize and handle various types of messages, which are described in our documentation below.

https://developer.twitter.com/en/docs/tutorials/consuming-streaming-data

Looking to use powershell, preferably the PSTwitterAPI.

Code here:

Import-Module PSTwitterAPI

Set-TwitterOAuthSettings -ApiKey $env:ApiKey -ApiSecret $env:ApiSecret -AccessToken $env:AccessToken -AccessTokenSecret $env:AccessTokenSecret

$TwitterStatuses = Get-TwitterStatuses_UserTimeline -screen_name 'mkellerman'

Foreach ($status in $TwitterStatuses) {
   Write-Host $status.text
}

Write-Host "done"

But I'm looking, preferably, for "the stream" of all tweets, something like all twitter "statuses".

Thufir
  • 8,216
  • 28
  • 125
  • 273
  • 1
    I don't think it's possible without external libraries. HTTP itself doesn't support streaming (although HTTP2 might), as per quick googling this seemed to be some separate protocol. So you'd to need to check if there is anything related on nuget.org. If there is some working java code, another option is to convert the jar to dll with IKVM – Mike Twc Jan 23 '20 at 22:15
  • 1
    The PSTwitterAPI module does provide the `Send-TwitterStatuses_Filter` cmdlet, but it just seems to cause the shell to hang when I tried it for myself. That should be hitting the correct Twitter API endpoint to receive the streaming data, though - I just am not sure how to expect to implement it. – Andy Piper Jan 27 '20 at 17:55

0 Answers0