The Simple Twitter API Wrapper Library For D Programming Language.
You can access twitter api with simple way.
import std.stdio,
std.regex,
std.json,
std.conv;
Twitter4D t4d = new Twitter4D([
"consumerKey" : "Your Consumer Key",
"consumerSecret" : "Your Consumer Secret",
"accessToken" : "Your Access Token",
"accessTokenSecret" : "Your Access Token Secret"]);
or
Twitter4D t4d = new Twitter4D(
["Your Consumer Key",
"Your Consumer Secret",
"Your Access Token",
"Your Access Token Secret"]);
t4d.request("POST", "statuses/update.json", ["status" : "test"]);
writeln(parseJSON(t4d.request("GET", "account/verify_credentials.json", ["":""])));
foreach(line; t4d.stream()){
if(match(line.to!string, regex(r"\{.*\}"))){
auto parsed = parseJSON(line.to!string);
if("text" in parsed.object)//tweet
writefln("\r[%s]:%s - [%s]", parsed.object["user"].object["name"],
parsed["created_at"],
parsed.object["text"]);
}
}
(Instance of Twitter4D).request("POST", "endPoint", ["additional" : "parameters"]);
Retrun value : plain json String
(Instance of Twitter4D).request("GET", "endPoint", ["additional": "parameters"]);
Return value : plain json String
default streaming api is UserStream
(Instance of Twitter4D).stream("endPoint URL(Full)");
Return value : streaming api session
###GET ACCESS TOKEN
Twitter4D t4d = new Twitter4D([
"consumerKey" : "Your Consumer Key",
"consumerSecret" : "Your Consumer Secret"]);
//Array style is also ok:
//Twitter4D t4d = new Twitter4d(["Your Consumer Key", "Your Consumer Secret"]);
string[string] accessTokens = t4d.getAccessToken;
//getAccessToken returns hash of accesstokens
//Return Value : ["accessToken" : "accessToken value",
// "accessTokenSecret" : "accessTokenSecret value"]
//If you want to set accesstokens to twitter4d instance
t4d.setAccessToken(accessTokens);
$ dmd FileName.d twitter4d.d -L-lcurl
The MIT LICENSE
Copyright (C) 2014 alphaKAI
alphaKAI
Twitter:@alpha_kai_NET
WebSite:alpha-kai-net.info