Giter Site home page Giter Site logo

thedavecarroll / bluebirdps Goto Github PK

View Code? Open in Web Editor NEW
60.0 6.0 11.0 1.59 MB

A Twitter Automation Client for PowerShell 7

Home Page: https://docs.bluebirdps.dev

License: MIT License

PowerShell 63.13% C# 36.87%
twitter-api powershell-module powershell twitter twitter-client powershell-gallery twitterdm tweets tweet twitter-api-v1

bluebirdps's Introduction

BluebirdPS: A Twitter Automation Client for PowerShell 7

BluebirdPS This is the project repo for BluebirdPS, a Twitter automation client for PowerShell 7.

PowerShell Gallery Downloads PowerShell Gallery Version (including pre-releases)

Standard v2

No Longer Active

Due to the recent changes with the Twitter API primarily regarding the new tiers, I will no longer continue developing this project. It should be considered stale and no new versions will be released. The latest version, v0.8.4, seeks to correct an issue in the Free Tier with Publish-Tweet.

This module will allow you to tweet, retweet, send direct messages, manage lists, and more, if you pay for the Basic or Pro Tiers. Otherwise, you should be able to tweet and delete tweets if using the Free Tier.

See Twitter API Documentation for details.

Community Module

This module was developed for the community and accepted feedback from the community to make it what it had become.

Pre-requisites

In order to use this module, you will need to have PowerShell 7 installed and a Twitter Developer account and a Twitter Project/App created and request to API v2 Early Access.

PowerShell 7

In order to support cross-platform scenarios, PowerShell 7 was chosen as the version for this new module. Focusing on a single version will also allow us to forego handling the API calls differently between Windows PowerShell and PowerShell 7.

Please see Installing various versions of PowerShell for instructions on installing PowerShell 7. You can install it on virtually any modern operating system - Windows, MacOS, or Linux.

Developer Account, Project, App, and Access Tokens

In order to use BluebirdPS, or any other Twitter API client or library, you will need to go through several steps to gain access to the API.

Applying for a Developer Account

You must apply for a developer account at https://developer.twitter.com/en/apply-for-access. This process could take a couple weeks.

Activate Developer Portal

Next, activate your developer portal at https://developer.twitter.com/content/developer-twitter/en/portal/opt-in.

Create a Project and Register a Developer App

You must have a project with a developer app created in the portal.

Apply for Access for the Twitter API v2: Early Access

Visit the Twitter API Getting Started page for details and additional links.

Generate Account Tokens

From the portal, you will need to generate the consumer key, otherwise called the API Key and Secret. The API Key is linked to your application.

You will also need to generate an Access Token and Secret. The Access Token is linked to your Twitter user account.

The application must be given access permissions of Read, Write, and Direct Message for full usage. At minimum, the application needs Read access for any Get- commands. Set-, Send-, and Publish-Tweet require Write access, while *-TwitterDM requires Direct Message access.

You can also generate a Bearer Token through the portal, or simply use the Set-TwitterAuthentication command. If your credentials are validated, the bearer token will be requested and set in the authentication file, as well.

Set-TwitterAuthentication
API Key: *************************
API Secret: **************************************************
Access Token: **************************************************
Access Token Secret: *********************************************

How to Install

From the PowerShell Gallery

Start PowerShell 7 and run the following command:

Install-Module -Name BluebirdPS -Scope CurrentUser

For more information, please visit the BluebirdPS page on the PowerShell Gallery.

From the GitHub Release Page

  1. Click here to go to the latest releases, then download the BluebirdPS.zip file attached to the release.
  2. Right-click the downloaded zip, select Properties, then unblock the file. This is to prevent having to unblock each file individually after unzipping.
  3. Unzip the archive.
  4. (Optional) Place the module somewhere in your PSModulePath.
    • You can view the paths listed by running the environment variable $env:PSModulePath

Building from the GitHub Repo

  1. Clone repo to a folder of your choice.
  2. Change into the local repo folder.
  3. Install and Import Module psake, BuildHelpers, PowerShellBuild
  4. Install dotnet (6.0)
  5. Run the build.ps1 script.
  6. Import-Module -Path .\BuildOutput\BluebirdPS\<module version>\BluebirdPS.psd1

Examples

Search-Tweet -SearchString "(from:thedavecarroll)"

Get-Tweet -Id 1398279333823791104

Publish-Tweet -TweetText "A new release of #BluebirdPS will soon be released. BluebirdPS is #PowerShell 7 Twitter automation client. Check it out! https://bit.ly/BluebirdPS"

Get-TwitterList -Id 1397040831777984512 | Add-TwitterListMember -UserName thedavecarroll,BluebirdPS

bluebirdps's People

Contributors

alagoutte avatar thedavecarroll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bluebirdps's Issues

[BUG] Get-TwitterDM is not allowed

Describe the bug
Running Get-TwitterDM produces an exception:

Line |
1063 |          Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters|          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | This application is not allowed to access or delete your direct messages.get-t

To Reproduce
Install module v0.1.1
Configure with secrets and export resources
Run Get-TwitterDM
I get the same error if I try to use Count.

Expected behavior
I should get 30 most DMs per the help.

PowerShell Environment (please complete the following information):

  • OS: Microsoft Windows 10.0.19042
  • Edition Core
  • Version 7.1.0

Additional context

Exception             : 
    Type       : Microsoft.PowerShell.Commands.HttpResponseException
    Response   : StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
                 {
                 Cache-Control: no-store, must-revalidate, no-cache, pre-check=0, post-check=0
                 Date: Tue, 24 Nov 2020 14:31:13 GMT
                 Pragma: no-cache
                 Server: tsa_b
                 Set-Cookie: personalization_id="v1_I75MF2AboHJIvuDKAS0UHg=="; Max-Age=63072000; Expires=Thu, 24 Nov 2022 14:31:13 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None
                 Set-Cookie: lang=en; Path=/
                 Set-Cookie: guest_id=v1%3A160622827308660937; Max-Age=63072000; Expires=Thu, 24 Nov 2022 14:31:13 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None
                 status: 403 Forbidden
                 Strict-Transport-Security: max-age=631138519
                 x-connection-hash: 3444663e8eaa0856782c4517920a5764
                 X-Content-Type-Options: nosniff
                 X-Frame-Options: SAMEORIGIN
                 x-rate-limit-limit: 15
                 x-rate-limit-remaining: 13
                 x-rate-limit-reset: 1606229146
                 x-response-time: 17
                 x-transaction: 00fbefa400b9179c
                 x-twitter-response-tags: BouncerCompliant
                 X-XSS-Protection: 0
                 Content-Disposition: attachment; filename=json.json
                 Content-Length: 110
                 Content-Type: application/json; charset=utf-8
                 Expires: Tue, 31 Mar 1981 05:00:00 GMT
                 Last-Modified: Tue, 24 Nov 2020 14:31:13 GMT
                 }
    TargetSite : 
        Name          : ThrowTerminatingError
        DeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    StackTrace : 
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
    Message    : This application is not allowed to access or delete your direct messages.
    Source     : System.Management.Automation
    HResult    : -2146233088
TargetObject          : https://api.twitter.com/1.1/direct_messages/events/list.json
CategoryInfo          : PermissionDenied: (https://api.twitter…es/events/list.json:String) [Invoke-TwitterCursorRequest], HttpResponseException
FullyQualifiedErrorId : Get-TwitterDM,Invoke-TwitterCursorRequest
InvocationInfo        : 
    MyCommand        : Invoke-TwitterCursorRequest
    ScriptLineNumber : 1063
    OffsetInLine     : 9
    HistoryId        : 257
    ScriptName       : C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1\BluebirdPS.psm1
    Line             : Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters -ReturnValue events
                       
    PositionMessage  : At C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1\BluebirdPS.psm1:1063 char:9
                       +         Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters …
                       +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1
    PSCommandPath    : C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1\BluebirdPS.psm1
    InvocationName   : Invoke-TwitterCursorRequest
    CommandOrigin    : Internal
ScriptStackTrace      : at Invoke-TwitterCursorRequest, C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1\BluebirdPS.psm1: line 418
                        at Get-TwitterDM, C:\Users\Jeff\Documents\PowerShell\Modules\bluebirdps\0.1.1\BluebirdPS.psm1: line 1063
                        at <ScriptBlock>, <No file>: line 1

Add function to generate queries

Create New-TwitterQuery that uses $PSBoundParameters of calling function to build new query.

Update functions to use the new function.

This will reduce the amount of duplicated code throughout the module.

Update $PSBoundParameters for Special Parameters

For all functions that use the New-TwitterQuery, ensure that $PSBoundParameters is updated, if necessary.

if ($UserId.Count -gt 100) {
    'More than 100 UserIds provided. Processing the first 100 only.'  | Write-Warning
    $PSBoundParameters['UserId'] = $PSBoundParameters['UserId'] | Select-Object -First 100
}
$Query = New-TwitterQuery -ApiParameters $PSBoundParameters

See Get-TwitterFriendship for an example.

Build script does not work on MacOS or Raspbian

The expanded build scripts do not run correctly on MacOS or Raspbian.

Update build/requirements.psd1

    'PowerShellBuild' = @{
        RequiredVersion = '0.5.0-beta1'
        AllowPrerelease = $true
    }

Update psakeBuild.ps1

  • Remove $PSBPreference.Build.OutDir and use default OutDir
  • Remove duplicate $PSBPreference.Build.CopyDirectories

Add an About help topic

At some point, it would be very helpful to include an about help topic for the module, especially given the required configurations. This can probably wait until your code base stabalizes.

Create functions to handle authentication

Create the following functions:

Set-TwitterAuthentication

  • securely reads input from user for 4 necessary keys and secrets
  • updates module scoped variable
  • option to persist - uses Export-TwitterAuthentication

Set-TwitterBearerToken

  • gets bearer token from Twitter with api key and secret
  • updates module scoped variable
  • option to persist - uses Export-TwitterAuthentication

Import-TwitterAuthentication

  • reads encrypted credential file
  • verifies file contains all required keys/attributes
  • if missing, corrupt, or incomplete, prompts user to use Set-TwitterAuthentication
  • called in root module as last item

Export-TwitterAuthentication

  • converts $OAuth module scoped variable to JSON
  • encrypts JSON using SecureString
  • saves encrypted string to $HOME\.TwitterPowerShell\twittercred.sav

New-TwitterSearchString - Create new function

Twitter Search Strings can be somewhat difficult, especially for newcomers to the module.

Create a New-TwitterSearchString that will assist the user in creating a valid search string that can be pipelined into Search-Tweet.

New-TwitterSearchString -From thedavecarroll -ExactPhrase 'homemade pizza' -Any 'these words' -NotAny 'bad malign' | Search-Tweet -ResultType Popular

Add Language and Configuration module variables

Currently, the module variables are the following.

  • $OAuthTokenSavePath
    • Used by Import-TwitterAuthentication and Export-TwitterAuthentication
  • $ApiEndpointsPath
    • Used by Get-TwitterApiEndpoint
  • $OAuth
    • Used by Import-TwitterAuthentication, Export-TwitterAuthentication, Set-TwitterAuthentication, Set-TwitterBearerToken, and Invoke-TwitterRequest. Eventually, it will be used by v2 API calls which will have their own Invoke private functions.
  • $TwitterErrorMapping
    • Used by New-TwitterErrorRecord
  • $RateLimitWarning
    • Used by Write-TwitterResponseData, Get-TwitterRateLimitWarning, and Set-TwitterRateLimitWarning.

Additional module variables should include the following.

How Should Rate Limits Be Handled?

Virtually all API endpoints have a rate limit, after which you must wait through a reset period.

Currently, there is a module scoped variable, $RateLimitWarning, that is set to $false when the module is imported.

You can using Get-TwitterRateLimitWarning to see if this Enabled or Disabled and use Set-TwitterRateLimitWarning to update the value.

At the moment, this throws a warning like the following prior to reaching the limit.

WARNING: The rate limit for this resource is 15. There are 1 remaining calls to this resource until 10/11/2020 6:18:52 PM.

When the rate limit is reached, it will throw a terminating error like the following.

Invoke-TwitterCursorRequest: C:\Program Files\Powershell\7\Modules\Twitter\public\Get-TwitterFollowers.ps1:49
Line |
  49 |          Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Rate limit of 15 has been reached. Please wait until 10/11/2020 6:18:52 PM before making another attempt for this resource.

For cursored and paged requests, the limit could be reached before all items have been returned. The way I have constructed Invoke-TwitterCursorRequest, the returned data is handed to the end user after each call. (At least, it should be working this way.)

Invoke-TwitterPageRequest will collect all of the returned data until all pages has been processed or the rate limit for that endpoint is reached, then the entire collection will be returned to the end user.


Please vote with the following:

  • 👍 Use Write-Warning and fail softly
  • 👎 Use Write-Error and fail at the Invoke-Twitter*Request level, but not the function
  • ❌ Use PSCmdLet.ThrowTerminatingError($_)

Please discuss below.

Thank you.

Errors on Import-Module

I installed the module from the PowerShell Gallery:

install-module bluebirdps -scope allusers

But get a number of errors on importing the module.

image

On my Windows 10 box I don't have a value for $env:HOME.

Convert-TweetDate

I'm sure you'll eventually have the commands write clean, structured objects to the pipeline. I'm using some adhoc tooling for the time being. Here's a function you can use that should convert the created_at datetime string, into a [datetime] object.

# Convert a value like "Tue Nov 24 15:15:19 +0000 2020" to Tuesday, November 24, 2020 10:15:19 AM which is local time
Function Convert-TweetDate {
    [cmdletbinding()]
    [outputtype([System.DateTime])]
    Param(
        [Parameter(Mandatory,Position=0,ValueFromPipelineByPropertyName)]
        [alias("Created_At")]
        [string]$Timestamp
    )
    Begin {}
    Process {
        Write-Verbose "Converting $timestamp"
        $dt = $timestamp.split()
        $dtstr  = "{0} {1} {2} {3} {4}" -f $dt[2],$dt[1],$dt[5],$dt[3],$dt[4]
        [datetime]::Parse($dtstr).toLocalTime()
    }
    end {}
}

I can then use it in a script like this:

#requires -version 7.1
#requires -module BluebirdPS

#get my recent Twitter mentions

. C:\scripts\Convert-TweetDate.ps1

Search-Tweet to:JeffHicks | Select-Object @{Name="Date";Expression={Convert-TweetDate $_.created_at}},
@{Name="Tweet";Expression={$_.text -replace "@JeffHicks",""}},@{name="from";Expression={$_.user.name}}

I'm assuming command output will eventually write properly formatted and typed data to the pipeline.

Add ReturnValue parameter to Invoke-TwitterCursorRequest

Add a ReturnValue parameter to Invoke-TwitterCursorRequest.

This will allow for tidier code in the public functions.

Instead of wrapping the returned values in an array and returning the required property like this:

$TwitterFollowers = Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters
@($TwitterFollowers.ids)

or this:

@(Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters).ids

You can simple provide the property as the ReturnValue, like this:

Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters -ReturnValue ids

This is a typical return for ids and users from a cursored request.

ids                 : {…}
next_cursor         : 0
next_cursor_str     : 0
previous_cursor     : 0
previous_cursor_str : 0
total_count         :

users               : {@{}...}
next_cursor         : 0
next_cursor_str     : 0
previous_cursor     : 0
previous_cursor_str : 0
total_count         :

Create private functions as required

  • Get-ErrorCategory
  • Get-ExceptionType
  • Get-SendMediaStatus
  • Get-TwitterException
  • Invoke-TwitterVerifyCredentials
  • New-TwitterErrorRecord (updated)
  • New-ValidationErrorRecord
  • Set-BluebirdPSAuthUser
  • Set-TwitterMediaAltImageText (updated)
  • Write-TwitterResponse

Write script to update TwitterApiEndpoints.json

As the Twitter API is vast and contains dozens of endpoints, an attempt was made to collect all of the endpoints into a single JSON file in hopes that the user could find it useful.

The function Get-TwitterApiEndpoint reads <moduleroot>resources\TwitterApiEndpoints.json.

This JSON should be updated to include all of the current endpoints supported by the module, and updated as new commands/endpoints are added.

A script should be written to generate the JSON instead of manual generation.

This documentation could come from the commands and their documentation, such as LINK.

[New Feature] All commands using parameter sets needs default parameter set in cmdletbinding

Is your feature request related to a problem? Please describe.
Get-TwitterUser has 2 parameter sets. You should define a default.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
I would make the Screenname the default and positional. A user is most likely to run:

Get-TwitterUser jeffhicks

Additional context
Add any other context or screenshots about the feature request here.

Move docs site to new domain

Move the docs site from bluebirdps.anovelidea.org to docs.bluebirdps.dev.

The work has been done on readthedocs.org.

Unfortunately, I did not use versioning for the external help url and when the docs are updated, any previous version would go to the latest version. This will break previous version online documentation where the command names are different, and the help will not be accurate.

This will be used to tack all of the documentation updates.

Add Commands for v1.1 Endpoints

CommandName ApiEndpoint
Add-TwitterList POST lists/create
Add-TwitterListMember POST lists/members/create, POST lists/members/create_all
Add-TwitterListSubscription POST lists/subscribers/create
Get-TwitterListSubscription GET lists/subscriptions
Get-TwitterListMembership GET lists/memberships
Remove-TwitterList POST lists/destroy
Remove-TwitterListMember POST lists/members/destroy, POST lists/members/destroy_all
Remove-TwitterListSubscription POST lists/subscribers/destroy
Set-TwitterList POST lists/update
Set-TwitterMutedUser POST mutes/users/create, POST mutes/users/destroy
Submit-TwitterUserAsSpam POST users/report_spam

Add C# Classes for Output and Processing

Create classes for the following objects:

Namespace BluebirdPS

  • TwitterObject
    • primary class that is inherited by API v1.1 and v2.0 objects
    • used to store and access original object from API
  • Helpers
    • any helper classes
  • OAuthParameters
    • replacement for current PowerShell custom class
  • ResponseData
    • used for storing history and sending information stream

Namespace BluebirdPS.APIV1

  • List : TwitterObject
  • Media : TwitterObject
  • SavedSearch : TwitterObject
  • AccountSettings : TwitterObject
  • DirectMessage : TwitterObject

Namespace BluebirdPS.APIV2

  • UpdateFriendship
    • to show the simple status of adding or removing a friend.

Namespace BluebirdPS.APIV2.Media

  • Media : TwitterObject

Namespace BluebirdPS.APIV2.Media.Metrics

  • Public
  • NonPublic
  • Organic
  • Promoted

Namespace BluebirdPS.APIV2.Objects

  • BaseEntity
  • Annotation : BaseEntity
  • CashTag : BaseEntity
  • HashTag : BaseEntity
  • Mention : BaseEntity
  • UrlTag : BaseEntity
  • Image
  • WithheldContent
  • Poll
  • PollOptions
  • Place

Namespace BluebirdPS.APIV2.TwitterTweet

  • Tweet : TwitterObject
  • ReferencedTweet
  • Attachments

Namespace BluebirdPS.APIV2.TwitterTweet.Metrics

  • Public
  • NonPublic
  • Organic
  • Promoted

Namespace BluebirdPS.APIV2.TwitterTweet.Context

  • ContextAnnotation
  • Domain
  • Entity

Namespace BluebirdPS.APIV2.TwitterUser

  • User : TwitterObject

Namespace BluebirdPS.APIV2.TwitterUser.Metrics

  • Public

Create Get-TwitterDM

Create function Get-TwitterDM to use the following endpoints:

  • direct_messages/events/show.json
  • direct_messages/events/list.json

The list endpoint will use Invoke-TwitterCursorRequest which will require special handling since this endpoint does not implement cursoring as other endpoints do.

Add C# Enums as required

To support the Twitter API v2, add an enum for each of the currently available field parameters for their expansion parameters.

  • TweetFields→ tweet.fields
  • UserFields→ user.fields
  • MediaFields→ media.fields
  • PollFields→ poll.fields
  • PlaceFields→ place.fields
  • MediaType
  • TweetIncludes
  • HttpMethod

Additionally, add static method to retrieve CSV list for a given enum.

Remove Endpoints JSON

Command to API endpoint is now handled by parsing the command's help.

Use the command Get-TwitterApiEndpoint to show the commands and their endpoints.

Create function to verify Twitter credentials

Create Test-TwitterAuthentication to verify Twitter credentials using the endpoint account/verify_credentials.json.

Use this new function in Set-TwitterAuthentication prior to exporting the credentials.

Use PowerShell Parameter Validation instead of manual parameter validation

This is more of a discussion point. When going through the code for the Get-TwitterFollowers function I noticed this:

    if ([string]::IsNullOrWhiteSpace($ScreenName) -and [string]::IsNullOrWhiteSpace($UserId)) {
        'You must supply either a ScreenName or UserId.' | Write-Warning
        return
    } elseif ($ScreenName.Length -gt 0 -and $UserId.Length -gt 0) {
        'You must supply a ScreenName or a UserId, but not both.' | Write-Warning
        return
    }

    if ($PSCmdlet.ParameterSetName -eq 'List') {
        if ($ResultsPerPage -and $ResultsPerPage -notin 1..200) {
            'For a list of follower objects, you can only request up to 200 user objects per page.' | Write-Warning
            return
        } else {
            $ResultsPerPage = 50
        }
    } else {
        if ($ResultsPerPage -and $ResultsPerPage -notin 1..5000) {
            'For list of follower ids, you can only request up to 5000 user is per page.' | Write-Warning
            return
        } else {
            $ResultsPerPage = 5000
        }
    }

Was wondering why this isn't being checked in the param() block instead of manually? I always tell people to leverage PowerShell's parameter validation rather than writing your own so this stood out to me.

Suppress Duplicate ChangeLog Entries

The command Get-ChangeLogUpdate in \build\BuildFunctions.psm1 can include duplicate entries in the output if there are multiple commits for the same issue. Suppress them.

Add Commands for API v2 Endpoints

Add command for the Twitter API v2 endpoints.

CommandName ApiEndpoint
Add-TwitterFriend POST /2/users/:id/following
Get-Tweet GET /2/tweets/:id, GET /2/tweets, GET /2/tweets/search/recent
Get-TweetLikes GET /2/tweets/:id/liking_users
Get-TwitterBlockedUser GET /2/users/:id/blocking
Get-TwitterFollowers GET /2/users/:id/followers
Get-TwitterFriends GET /2/users/:id/following
Get-TwitterTimeline GET /2/users/:id/tweets, GET /2/users/:id/mentions
Get-TwitterUser GET /2/users/by, GET /2/users/by/username/:username, GET /2/users, GET /2/users/:id
Remove-TwitterFriend DELETE /2/users/:source_user_id/following/:target_user_id
Search-Tweet GET /2/tweets/search/recent
Set-TweetLike POST /2/users/:id/likes, DELETE /2/users/:id/likes/:tweet_id
Set-TweetReply PUT /2/tweets/:id/hidden
Set-TwitterBlockedUser POST /2/users/:id/blocking, DELETE /2/users/:source_user_id/blocking/:target_user_id

Calling 'Get-TwitterFollowers' results in exception

I have setup $OAuth hashtable with the correct keys (I verified they work by using the PSTwitterAPI module):

> $OAuth = @{ ApiKey = 'blah'; ApiSecret = 'blah'; AccessToken = 'blah; AccessTokenSecret = 'blah' }

When I call `Get-TwitterFollowers -Screenname 'pauby' -Verbose' I get this error:

> Get-TwitterFollowers -ScreenName 'pauby' -Verbose
SetValueInvocationException: C:\Users\Paul\git\pauby\others\powershellmodules_twitter\Twitter\classes\OAuthParameters.Class.psm1:202
Line |
 202 |          $this.UriBuilder = $this.BaseUri
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception setting "UriBuilder": "Cannot convert value "" to type "System.UriBuilder". Error: "Invalid
     | URI: The hostname could not be parsed.""

InvalidOperation: C:\Users\Paul\git\pauby\others\powershellmodules_twitter\Twitter\public\Get-TwitterFollowers.ps1:70
Line |
  70 |          $OAuthParameters.BaseUri = 'https://api.twitter.com/1.1/follo …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The property 'BaseUri' cannot be found on this object. Verify that the property exists and can be set.

InvalidOperation: C:\Users\Paul\git\pauby\others\powershellmodules_twitter\Twitter\public\Get-TwitterFollowers.ps1:73
Line |
  73 |      $OAuthParameters.SetQuery($Query)
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | You cannot call a method on a null-valued expression.

Invoke-TwitterCursorRequest: C:\Users\Paul\git\pauby\others\powershellmodules_twitter\Twitter\public\Get-TwitterFollowers.ps1:79
Line |
  79 |  … owers = Invoke-TwitterCursorRequest -OAuthParameters $OAuthParameters
     |                                                         ~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'OAuthParameters' because it is null

I've only had a cursory look over this at the moment so what I'm about to say may be nonsense 😄

This line sets the $BaseUri to $null?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.