Git Product home page Git Product logo

twurl's Introduction

+-------+
| Twurl |
+-------+

Twurl is like curl, but tailored specifically for the Twitter API.
It knows how to grant an access token to a client application for
a specified user and then sign all requests with that access token.

It also provides other development and debugging conveniences such
as defining aliases for common requests, as well as support for
multiple access tokens to easily switch between different client
applications and Twitter accounts.

+-----------------+
| Getting Started |
+-----------------+

The first thing you have to do is register an OAuth application
to get a consumer key and secret.

  https://apps.twitter.com/app/new

When you have your consumer key and its secret you authorize
your Twitter account to make API requests with your consumer key
and secret.

  % twurl authorize --consumer-key key       \
                    --consumer-secret secret

This will return an URL that you should open up in your browser.
Authenticate to Twitter, and then enter the returned PIN back into
the terminal.  Assuming all that works well, you will be authorized
to make requests with the API. Twurl will tell you as much.

If your consumer application has xAuth enabled, then you can use
a variant of the above

  % twurl authorize -u username -p password  \
                    --consumer-key key       \
                    --consumer-secret secret

And, again assuming your username, password, key and secret is
correct, will authorize you in one step.

+-----------------+
| Making Requests |
+-----------------+

The simplest request just requires that you specify the path you
want to request.

  % twurl /1.1/statuses/home_timeline.json

Similar to curl, a GET request is performed by default.

You can implicitly perform a POST request by passing the -d option,
which specifies POST parameters.

  % twurl -d 'status=Testing twurl' /1.1/statuses/update.json

You can explicitly specify what request method to perform with
the -X (or --request-method) option.

  % twurl -X POST /1.1/statuses/destroy/1234567890.json

+------------------+
| Creating aliases |
+------------------+

  % twurl alias h /1.1/statuses/home_timeline.json

You can then use "h" in place of the full path.

  % twurl h

Paths that require additional options such as request parameters for example can
be used with aliases the same as with full explicit paths, just as you might
expect.

  % twurl alias tweet /1.1/statuses/update.json
  % twurl tweet -d "status=Aliases in twurl are convenient"

+-------------------------------+
| Changing your default profile |
+-------------------------------+

The first time you authorize a client application to make requests on behalf of your account, twurl stores your access token information in its .twurlrc file. Subsequent requests will use this profile as the default profile. You can use the 'accounts' subcommand to see what client applications have been authorized for what user names:

  % twurl accounts
  noradio
    HQsAGcBm5MQT4n6j7qVJw
    hhC7Koy2zRsTZvQh1hVlSA (default)
  testiverse
    guT9RsJbNQgVe6AwoY9BA

Notice that one of those consumer keys is marked as the default. To change the default use the 'set' subcommand, passing then either just the username, if it's unambiguous, or the username and consumer key pair if it isn't unambiguous:

  % twurl set default testiverse
  % twurl accounts
  noradio
    HQsAGcBm5MQT4n6j7qVJw
    hhC7Koy2zRsTZvQh1hVlSA
  testiverse
    guT9RsJbNQgVe6AwoY9BA (default)

  % twurl set default noradio HQsAGcBm5MQT4n6j7qVJw
  % twurl accounts
  noradio
    HQsAGcBm5MQT4n6j7qVJw (default)
    hhC7Koy2zRsTZvQh1hVlSA
  testiverse
    guT9RsJbNQgVe6AwoY9BA

+--------------+
| Contributors |
+--------------+

Marcel Molina <[email protected]> / @noradio
Erik Michaels-Ober / @sferik

twurl's People

Contributors

caniszczyk avatar esbie avatar j3h avatar jaakko-sf avatar kurrik avatar marcel avatar nimitalt avatar sanmai avatar sferik avatar sylvaincarle avatar

Watchers

 avatar

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.