Client library for docomo API written in Ruby.
CAUTION: Docomoru does not work now. See #3
Install
docomoru can be installed from rubygems.org as a gem.
gem install docomoru
Authentication
To use docomo API via docomoru, you need to get docomo API Key.
- Sign-in to https://dev.smt.docomo.ne.jp/
- Register new application
- Generate API Key
Supported APIs
Currently docomoru is supporting the following APIs.
Usage
You can use docomoru as a library on Ruby code or an executable on CLI.
Library
Create an instance of Docomoru::Client
,
then call a method to send an HTTP request to docomo API.
Each method returns Docomoru::Response
that has status code, headers, and body values.
Here is an example code to use Dialogue API via docomoru.
As you can see, Docomoru::Client
provides low-level interface of HTTP,
so you may need some wrapper class to use it from your application.
client = Docomoru::Client.new(api_key: ENV["DOCOMO_API_KEY"])
response = client.create_dialogue("Gemつくりました")
response.status #=> 200
response.headers #=> {
"Asyncserviceinvoke" => "false",
"Content-Type" => "application/json;charset=UTF-8",
"Date" => "Fri, 05 Dec 2014 15:10:11 GMT",
"Content-Length" => "165",
"Connection" => "Close"
}
response.body #=> {
"utt" => "gemに登録されるのでしょうかね",
"yomi" => "gemに登録されるのでしょうかね",
"mode" => "dialog",
"da" => "12",
"context" => "dXIgT9u1_XKfO1QbaVkAGQ"
}
CLI
docomoru
executable is bundled to call docomo API from CLI.
This executable handily creates an instance of Docomoru::Client
with given API Key,
then call the specified method, and returns its response.
$ docomoru <method> <arguments> [options]
| | |
| | `-- -a, --api-key (or use DOCOMO_API_KEY env)
| | -h, --help
| | --header
| | --no-body
| |
| `------------- required arguments for the method
|
`------------------------ method name
$ docomoru create_dialogue かわいい
$ docomoru create_knowledge Rubyの作者は誰ですか