pasadinhas / oauth
PHP 5.4+ OAuth (1 and 2) client library
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: 3.7.*
- predis/predis: 0.8.*@dev
- symfony/http-foundation: ~2.1
Suggests
- ext-openssl: Allows for usage of secure connections with the stream-based HTTP client.
- predis/predis: Allows using the Redis storage backend.
- symfony/http-foundation: Allows using the Symfony Session storage backend.
README
php-oauth-lib provides OAuth support in PHP 5.4+ and is very easy to integrate with any project which requires an OAuth client.
Installation
This library can be found on Packagist. The recommended way to install this is through composer.
Edit your composer.json
and add:
{ "require": { "pasadinhas/oauth": "~1.0.0" } }
And then update your dependencies with:
$ composer update
Extend this package
If you implement any new Service, HTTP Client or Storage, make a pull request so I can add it to this package. Don't forget to write some tests for it!
Services
You can implement any service with custim requirements by extending and implementing the AbstractService
class of the corresponding OAuth version. You will need to implement the abstract methods and should be ready to go! In order to parse the token response from OAuth2 it's recommended to use TokenParserTrait
provided.
HTTP Clients
You can implement any HTTP Client you desire. Just create a class that implements OAuth\Common\Http\ClientInterface
. By default a CurlClient
and a StreamClient
are provided.
Storage
The same for storage. Just implement the OAuth\Common\Token\TokenStorageInterface
and use it in your app.
Service support
The library supports both OAuth 1.x and OAuth 2.0 compliant services. A list of currently implemented services can be found below.
Included service implementations
- OAuth1
- BitBucket
- Etsy
- FitBit
- Flickr
- Scoop.it!
- Tumblr
- Yahoo
- OAuth2
- Amazon
- BitLy
- Box
- Dailymotion
- Dropbox
- FenixEdu
- Foursquare
- GitHub
- Harvest
- Heroku
- Mailchimp
- Microsoft
- PayPal
- RunKeeper
- SoundCloud
- Vkontakte
- Yammer
- more to come! (Make pull requests if you have any!)
Examples
Examples of basic usage are located in the examples/ directory.
Usage
For usage with complete auth flow, please see the examples.
Framework Integration
- Laravel 4: I have a package for the library. It has a Service Provider which makes using this package even easier!
Tests
To run the tests, you must install dependencies with composer install --dev