Skip to content

a library for working with Twitter's REST v1.1 API for application authentication only

Notifications You must be signed in to change notification settings

iamdtang/twitter-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitter API Library for Applications

Install

You can install this package through Composer:

https://packagist.org/packages/tang/twitter-rest-api

Getting Started

Visit https://dev.twitter.com/apps/ to define an application on Twitter and save your API key information.

Currently this library only supports application-only authentication. This means that any request to the API for endpoints that require user context, such as posting tweets, will not work.

Searching tweets

$twitterSearch = new Tang\TwitterRestApi\TwitterApi([
	'api_key' => API_KEY,
	'api_secret' => API_SECRET
]);

$json = $twitterSearch->authenticate()->get('search/tweets', [
	'q' => 'laravel'
]);

You can pass in a 3rd argument to the TwitterApi::get() and this will return the JSON decoded.

Getting a user's timeline

$twitterApi = new Tang\TwitterRestApi\TwitterApi([
	'api_key' => API_KEY,
	'api_secret' => API_SECRET
]);

$json = $twitterApi->authenticate()->get('statuses/user_timeline', [
	'screen_name' => 'uscitp',
	'count' => 10,
	'exclude_replies' => true
]);

You can pass in any application level base route to the get method along with query string params passed as an array.

Working Examples

See the examples folder for working examples

About

a library for working with Twitter's REST v1.1 API for application authentication only

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages