Skip to content
Jabran Rafique

PHP library for Twitter API v1.1

1 minute read

View source

This project is deprecated and no longer maintained.

Use Fetchwitter instead. It replaces this library.

How it works

Step 1: Create an application

Sign in at https://dev.twitter.com/apps and create a new application. Once you fill in the required fields, Twitter generates the credentials. You only need the consumer key and consumer secret.

Step 2: Exchange credentials for an access token

Make a POST request to the API's OAuth endpoint to swap those credentials for an access token. This request needs Authorization headers, and the response contains an app level bearer access token. Save or cache the token so you don't request a new one every time.

Step 3: Request the feed

With the access token you can call the Twitter API endpoints and get data back. These requests also need Authorization headers.

The API returns tweets as plain text, so links, hashtags and mentions come back unlinked. A regex match and replace fixes that, and the example includes one as the text2tweet() function.

License

MIT License