|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this_program `()(string client_id, string client_secret, |
void|string redirect_uri, |
void|string|array(string)|multiset(string) scope) |
{ |
return V1_1(client_id, client_secret, redirect_uri, scope); |
} |
|
class V1_1 |
{ |
inherit WebApi.Api : parent; |
|
constant API_URI = "https://api.twitter.com/1.1/"; |
|
protected constant AuthClass = Auth.Twitter; |
|
|
|
|
|
|
Any `any() |
{ |
return _any || (_any = Any()); |
} |
|
|
|
|
|
|
|
|
|
|
mapping get(string path, void|ParamsArg params, void|Callback cb) |
{ |
return `any()->get(path, params, cb); |
} |
|
|
|
|
|
|
|
|
|
|
mapping put(string path, void|ParamsArg params, void|Callback cb) |
{ |
return `any()->put(path, params, cb); |
} |
|
|
|
|
|
|
|
|
|
|
|
mapping post(string path, void|ParamsArg params, void|string data, |
void|Callback cb) |
{ |
return `any()->post(path, params, data, cb); |
} |
|
|
|
|
|
|
|
|
|
|
mapping delete(string path, void|ParamsArg params, void|Callback cb) |
{ |
return `any()->delete(path, params, cb); |
} |
|
|
protected mapping default_params() |
{ |
return ([ "format" : "json" ]); |
} |
|
|
protected class Method |
{ |
inherit WebApi.Api.Method; |
|
|
public mixed get(string s, void|ParamsArg p, void|Callback cb) |
{ |
return parent::get(get_uri(METHOD_PATH + s), p, cb); |
} |
|
|
public mixed put(string s, void|ParamsArg p, void|Callback cb) |
{ |
return parent::put(get_uri(METHOD_PATH + s), p, cb); |
} |
|
|
public mixed post(string s, void|ParamsArg p, void|string data, |
void|Callback cb) |
{ |
return parent::post(get_uri(METHOD_PATH + s), p, data, cb); |
} |
|
|
public mixed delete(string s, void|ParamsArg p, void|Callback cb) |
{ |
return parent::delete(get_uri(METHOD_PATH + s), p, cb); |
} |
} |
|
|
protected class Any |
{ |
inherit Method; |
protected constant METHOD_PATH = "/"; |
} |
|
mixed call(string api_method, void|ParamsArg params, |
void|string http_method, void|string data, void|Callback cb) |
|
{ |
if (!has_suffix(api_method, ".json")) |
api_method += ".json"; |
|
string res = auth->call(api_method, params, http_method); |
|
mixed result = Standards.JSON.decode(res); |
|
return result; |
} |
|
private Any _any; |
} |
|
|