Recommend this page to a friend! |
Download .zip |
Info | Example | View files (48) | Download .zip | Reputation | Support forum (1) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2024-01-09 (4 days ago) | Not yet rated by the users | Total: 452 | All time: 6,148 This week: 120 |
Version | License | PHP version | Categories | |||
ohmy-auth 0.0.16 | BSD License | 5.3 | PHP 5, User Management, Web services |
Description | Author | |||||||||||||
This package can Obtain authorization to access APIs using OAuth. |
|
<?php require_once __DIR__ . '/../vendor/autoload.php'; |
ohmy-auth (Oma) is a PHP library that simplifies OAuth into a fluent interface:
use ohmy\Auth1;
Auth1::legs(2)
->set('key', 'key')
->set('secret', 'secret')
->request('http://term.ie/oauth/example/request_token.php')
->access('http://term.ie/oauth/example/access_token.php')
->GET('http://term.ie/oauth/example/echo_api.php')
->then(function($data) {
# got data
});
Oma only requires PHP (>= 5.3) and the usual extensions for Curl (`
curl_init()`
, `
curl_setopt()`
, etc), JSON (`
json_encode()`
, `
json_decode()`
) and sessions (`
session_start()`
, `
session_destroy()`
).
The best way to install Oma is via Composer. Just add `
ohmy/auth`
to your project's `
composer.json`
and run `
composer install`
. eg:
{
"require": {
"ohmy/auth": "*"
}
}
If you prefer not to use Composer, you can download an archive or clone this repo and put `
src/ohmy`
into your project setup.
use ohmy\Auth1;
# do 2-legged oauth
$termie = Auth1::legs(2)
# configuration
->set('key', 'key')
->set('secret', 'secret')
# oauth flow
->request('http://term.ie/oauth/example/request_token.php')
->access('http://term.ie/oauth/example/access_token.php');
# api call
$termie->GET('http://term.ie/oauth/example/echo_api.php')
->then(function($data) {
# got data
});
Note: This requires sessions in order to save data between redirects. This will not work properly without sessions!
use ohmy\Auth1;
# do 3-legged oauth
$tumblr = Auth1::legs(3)
# configuration
->set(array(
'consumer_key' => 'your_consumer_key',
'consumer_secret' => 'your_consumer_secret',
'callback' => 'your_callback_url'
))
# oauth flow
->request('http://www.tumblr.com/oauth/request_token')
->authorize('http://www.tumblr.com/oauth/authorize')
->access('http://www.tumblr.com/oauth/access_token');
# access tumblr api
$tumblr->GET('https://api.tumblr.com/v2/user/info')
->then(function($data) {
# got user data
});
use ohmy\Auth2;
# do 3-legged oauth
$github = Auth2::legs(3)
# configuration
->set(array(
'id' => 'your_github_client_id',
'secret' => 'your_github_client_secret',
'redirect' => 'your_redirect_uri'
))
# oauth flow
->authorize('https://github.com/login/oauth/authorize')
->access('https://github.com/login/oauth/access_token')
->finally(function($data) use(&$access_token) {
$access_token = $data['access_token'];
});
# access github api
$github->GET("https://api.github.com/user?access_token=$access_token", null, array('User-Agent' => 'ohmy-auth'))
->then(function($data) {
# got user data
});
- Facebook - Fitbit - GitHub - Google+ - Instagram - LinkedIn - Live - Tumblr - Twitter - Yahoo
- __PHP license__: PHP License - __ohmy-auth__: New BSD License.
Files |
File | Role | Description | ||
---|---|---|---|---|
examples (11 files) | ||||
src (1 directory) | ||||
tests (5 files) | ||||
vendor (1 file, 1 directory) | ||||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | Auxiliary data | ||
phpunit.oauth1.xml | Data | Auxiliary data | ||
README.md | Doc. | Auxiliary data |
Files | / | examples |
File | Role | Description |
---|---|---|
facebook.php | Example | Example script |
fitbit.php | Example | Example script |
github.php | Example | Example script |
google.php | Example | Example script |
instagram.php | Example | Example script |
linkedin.php | Example | Example script |
live.php | Example | Example script |
term.ie.php | Example | Example script |
tumblr.php | Example | Example script |
twitter.php | Example | Example script |
yahoo.php | Example | Example script |
Files | / | src | / | ohmy | / | Auth |
File | Role | Description |
---|---|---|
Flow.php | Class | Class source |
Promise.php | Class | Class source |
Files | / | src | / | ohmy | / | Auth1 |
File | Role | Description | ||
---|---|---|---|---|
Flow (2 files, 2 directories) | ||||
Security (1 file) | ||||
Auth1Flow.php | Class | Class source |
Files | / | src | / | ohmy | / | Auth1 | / | Flow |
File | Role | Description | ||
---|---|---|---|---|
ThreeLegged (3 files) | ||||
TwoLegged (2 files) | ||||
ThreeLegged.php | Class | Class source | ||
TwoLegged.php | Class | Class source |
Files | / | src | / | ohmy | / | Auth1 | / | Flow | / | ThreeLegged |
File | Role | Description |
---|---|---|
Access.php | Class | Class source |
Authorize.php | Class | Class source |
Request.php | Class | Class source |
Files | / | src | / | ohmy | / | Auth1 | / | Flow | / | TwoLegged |
File | Role | Description |
---|---|---|
Access.php | Class | Class source |
Request.php | Class | Class source |
Files | / | src | / | ohmy | / | Auth2 |
File | Role | Description | ||
---|---|---|---|---|
Flow (1 file, 1 directory) | ||||
Auth2Flow.php | Class | Class source |
Files | / | src | / | ohmy | / | Auth2 | / | Flow |
File | Role | Description | ||
---|---|---|---|---|
ThreeLegged (2 files) | ||||
ThreeLegged.php | Class | Class source |
Files | / | src | / | ohmy | / | Auth2 | / | Flow | / | ThreeLegged |
File | Role | Description |
---|---|---|
Access.php | Class | Class source |
Authorize.php | Class | Class source |
Files | / | src | / | ohmy | / | Components |
File | Role | Description | ||
---|---|---|---|---|
Http (1 directory) | ||||
Session (1 file) | ||||
Http.php | Class | Class source | ||
Session.php | Class | Class source |
Files | / | src | / | ohmy | / | Components | / | Http | / | Curl |
File | Role | Description |
---|---|---|
Request.php | Class | Class source |
Response.php | Class | Class source |
Files | / | tests |
File | Role | Description |
---|---|---|
Auth1Test.php | Test | Unit test script |
Auth2Test.php | Test | Unit test script |
bootstrap.php | Aux. | Unit test script |
PromiseTest.php | Test | Unit test script |
SignatureTest.php | Test | Unit test script |
Files | / | vendor | / | composer |
File | Role | Description |
---|---|---|
autoload_classmap.php | Aux. | Auxiliary script |
autoload_namespaces.php | Aux. | Auxiliary script |
autoload_psr4.php | Aux. | Auxiliary script |
autoload_real.php | Class | Auxiliary script |
ClassLoader.php | Class | Auxiliary script |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.
Related pages |
Homepage |
GitHub repository |