Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tonytonyjan/tjplurk

Plurk API wrapper
https://github.com/tonytonyjan/tjplurk

Last synced: about 1 month ago
JSON representation

Plurk API wrapper

Awesome Lists containing this project

README

        

## Install

```
$ gem install tjplurk
```

## Usage

```ruby
api = Tjplurk::API.new CONSUMER_KEY, CONSUMER_SECRET, TOKEN_KEY, TOKEN_SECRET
api.request('/APP/Users/me') # => Hash object
api.request('/APP/Timeline/plurkAdd', content: 'haha', qualifier: 'says') # => Hash object
```

You can save your `CONSUMER_KEY`, `CONSUMER_SECRET`, `TOKEN_KEY`, `TOKEN_SECRET` in `$HOME/.tjplurk` per line, and `Tjplurk::API.new` will work as well, for example:

```ruby
api = Tjplurk::API.new
api.request('/APP/Users/me')
```

Set `ENV['TJPLURK_FILE']` to customize the config file path.

### Real Time Notification

```ruby
require 'tjplurk'

api = Tjplurk::API.new
api.real_time do |plurk|
jj plurk
end
```

### Examples

- [Echo](https://github.com/tonytonyjan/tjplurk/blob/master/examples/echo.rb)
- [Plurk Robot](https://github.com/tonytonyjan/tjplurk/blob/master/examples/robot.rb)

## Command Line Usage

For the first time, you should use `tjplurk auth` to get access token and secret:

```
$ tjplurk auth CONSUMER_KEY CONSUMER_SECRET
Authorize URL: http://www.plurk.com/OAuth/authorize?oauth_token=************
Enter Verification Number: *****
Key & secret successfully saved to "$HOME/.tjplurk".
```

Your consumer key/secret and token key/secret will be saved to `$HOME/.tjplurk`. Then you can use all Plurk API:

```
$ tjplurk api /APP/Users/me
$ tjplurk api /APP/Timeline/plurkAdd "content=hello world" qualifier=says
```

For more available API paths, see http://www.plurk.com/API

### Pretty print

```
$ tjplurk api /APP/Users/me | python -mjson.tool
```

```
$ tjplurk api /APP/Users/me | ruby -rjson -e 'jj JSON.parse(ARGF.read)'
```

### Commands

```
tjplurk auth CONSUMER_KEY CONSUMER_SECRET # get access token interactivly.
tjplurk api PATH ["FOO=BAR" ...] # send an API request.
```

## Develop

Before running rspec, please create `$HOME/.tjplurk` first.