Tori(the Twitter Bird in Japanese) kit -> Toriki.
Ultra lightweight Twitter tool for Unity. supports the SingleSignOn with Twitter app and Twitter API invocation.
Currently, Toriki requires Twitter application in supported platflorms.
- iOS
- Android
- WebGL(under development.)
with Unity 2018.x or later.
Use UnityPackage in releases.
static TwitterSettings()
{
ConsumerKey = string.Empty;// change here.
ConsumerSecret = string.Empty;// change here.
if (string.IsNullOrEmpty(ConsumerKey))
{
Debug.Log("ConsumerKey is null. please write some code for setting ConsumerKey.");
}
if (string.IsNullOrEmpty(ConsumerSecret))
{
Debug.Log("ConsumerSecret is null. please write some code for setting ConsumerSecret.");
}
}
get AccessToken & AccessTokenSecret from Twitter.
TwitterAPI.InitWithLogin(
(nickname, token, secret) =>
{
// nickname, accesstoken, accesstokensecret is available.
// also TwitterAPI is ready now.
},
(errorCode, message) =>
{
// failed to log in to Twitter.
Debug.Log("login error:" + errorCode + " message:" + message);
}
or
log in with stored AccessToken & AccessTokenSecret.
TwitterAPI.InitWithToken("ACCESS_TOKEN", "ACCESS_SECRET");
after log in to Twitter, you can use Twitter APIs.
// tweet API example.
TwitterAPI.Post(
"https://api.twitter.com/1.1/statuses/update.json",
new SortedDictionary<string, string>
{
{"status", "#LoveToriki. "}
},
result =>
{
Debug.Log("update result:" + result);
},
(code, errors) =>
{
Debug.Log("update code:" + code);
}
);