twitter / twurl

OAuth-enabled curl for the Twitter API
https://developer.twitter.com
MIT License
1.8k stars 301 forks source link

Feature Request: username selection command line option #10

Closed HamishMacEwan closed 4 years ago

HamishMacEwan commented 14 years ago

Hi,

The two step process to ensure the correct username is used (in a script for example):

twurl set default username twurl tweet -d status="why's that?"

Seems a bit awkward. Couldn't -u be used for this or that would be curly?

iPhoneDevGuy commented 13 years ago

Modifying the file " GemPath /gems/twurl-0.6.3/lib/twurl/oauth_client.rb" in following way (replace line 14 with the 3 lines) solves this issue:

 #   elsif options.username || (options.command == 'authorize')
 # modified by me to have secondary twitter account specified from CLI using -u option
      elsif options.username
        load_client_for_username(options.username)
      elsif (options.command == 'authorize')
thwarted commented 13 years ago

I discovered the above patch on my own, as I need this feature also. Not having to change the default before invoking also means you can run two requests simultaneously without a race condition.

nublaii commented 11 years ago

I'm using this workaround and it works perfectly. It should get into the master

AgoraSecurity commented 5 years ago

+1

AgoraSecurity commented 5 years ago

If it helps someone, I created this small ruby code that helps achieve the goal:

require 'twurl'

path = "/1.1/account/verify_credentials.json?include_entities=false&skip_status=true"

options = Twurl.options.dup
options.command = "get"
options.path = path
options.data = []
client = Twurl::OAuthClient.load_client_for_username(username)

Twurl::RequestController.dispatch(client, options)
smaeda-ks commented 4 years ago

created https://github.com/twitter/twurl/pull/125

smaeda-ks commented 4 years ago

This is merged into master.

smaeda-ks commented 4 years ago

https://github.com/twitter/twurl/releases/tag/v0.9.4

Closing.