Application-only API

Twitter offers applications the ability to issue authenticated requests on behalf of the application itself (as opposed to on behalf of a specific user). Twitter's implementation is based on the Client Credentials Grant flow of the OAuth 2 specification.

With Application-only authentication you don't have the context of an authenticated user and this means that any request to API for endpoints that require user context, such as posting tweets, will not work. However, the set of endpoints that will still be available can have a higher rate limit.

Your app will be able to, for example:

  • Pull user timelines;
  • Access friends and followers of any account;
  • Access lists resources;
  • Search in tweets;
  • Retrieve any user information;

And it won't be able to:

  • Post tweets or other resources;
  • Connect in Streaming endpoints;
  • Search for users;
  • Use any geo endpoint;
  • Access DMs or account credentials;

You do not have to auth User in order to use application only API. It can be used in the editor and on any platform. The API Methods description can be found under API References chapter.  Usage example can be found below.

 

user_timeline

Twitter documentation:

https://dev.twitter.com/docs/api/1/get/statuses/user_timeline

Use example:

TW_UserTimeLineRequest r =  TW_UserTimeLineRequest.Create();
r.ActionComplete += OnTimeLineRequestComplete;
r.AddParam("screen_name", "unity3d");
r.AddParam("count", "1");
r.Send();


private void OnTimeLineRequestComplete(TW_APIRequstResult result) {

	if(result.IsSucceeded) {

		string msg ;
		if(result.tweets.Count > 0) {
			msg = "Last Tweet text:" + "\n";
			msg+= result.tweets[0].text;
		} else {
			msg = "NO tweens found";
		}

	Debug.Log(msg);
	} else {
		Debug.Log(result.responce);
	}	
}

 

users/lookup

Twitter documentation:

https://dev.twitter.com/docs/api/1.1/get/users/lookup

Use example:

TW_UsersLookUpRequest r =  TW_UsersLookUpRequest.Create();
r.ActionComplete += OnLookUpRequestComplete;
r.AddParam("screen_name", "unity3d");
r.Send();

private void OnLookUpRequestComplete(TW_APIRequstResult result) {
		
	if(result.IsSucceeded) {
		string msg = "User Id: ";
		msg+= result.users[0].id;
		msg+= "\n";
		msg+= "User Name:" + result.users[0].name;
		
		Debug.Log(msg);
	} else {
		Debug.Log(result.responce);
	}
}

 

friends/ids

Twitter documentation:

https://dev.twitter.com/docs/api/1.1/get/friends/ids

 

Use example:

TW_FriendsIdsRequest r =  TW_FriendsIdsRequest.Create();
r.ActionComplete += OnIdsLoaded;
r.AddParam("screen_name", "unity3d");
r.Send();


private void OnIdsLoaded(TW_APIRequstResult result) {

	if(result.IsSucceeded) {
		Debug.Log( "Totals ids loaded: " + result.ids.Count);
	} else {
		Debug.Log(result.responce);
	}
}

 

followers/ids

Twitter documentation:

https://dev.twitter.com/docs/api/1.1/get/followers/ids

 

Use example:

TW_FollowersIdsRequest r =  TW_FollowersIdsRequest.Create();
r.ActionComplete += OnIdsLoaded;
r.AddParam("screen_name", "unity3d");
r.Send();


private void OnIdsLoaded(TW_APIRequstResult result) {

    if(result.IsSucceeded) {
		Debug.Log( "Totals ids loaded: " + result.ids.Count);
	} else {
		Debug.Log(result.responce);
	}
}

 

search/tweets

Twitter documentation:

https://dev.twitter.com/docs/api/1.1/get/search/tweets

 

Use example:

TW_SearchTweetsRequest r =  TW_SearchTweetsRequest.Create();
r.ActionComplete += OnSearchRequestComplete;
r.AddParam("q", "@noradio");
r.AddParam("count", "1");
r.Send();


private void OnSearchRequestComplete(TW_APIRequstResult result) {

	if(result.IsSucceeded) {
		string msg = "Tweet text:" + "\n";
		msg+= result.tweets[0].text;
			

	Debug.Log(msg);
	} else {
		Debug.Log(result.responce);
	}		
}