dev-master
9999999-dev https://github.com/djchen/oauth1-phpA simple and easy to use OAuth1 library for PHP
MIT
The Requires
- php >=5.3.0
by Dan Chen
oauth oauth1
Wallogit.com
2017 © Pedro Peláez
A simple and easy to use OAuth1 library for PHP
oauth1-php is a super simple and basic PHP library for making OAuth 1.0 requests., (*1)
{
"require" : {
"djchen/oauth1-php" : "dev-master"
},
"autoload": {
"psr-0": {"djchen": "src"}
}
}
Requires PHP 5.3+ and cURL The Unirest library is used to make HTTP requests and is included in the project., (*2)
$oauth = new OAuth1(array(
'consumerKey' => 'oauth_consumer_key',
'consumerSecret' => 'oauth_consumer_secret',
'token' => 'oauth_token', // optional
'tokenSecret' => 'oauth_token_secret', // optional
'requestTokenUrl' => 'request_token_url',
'accessTokenUrl' => 'access_token_url',
));
$result = $oauth->requestToken('callback_url');
$result is an array with the response params => values, (*3)
$result = $oauth->accessToken('oauth_token', 'oauth_token_secret', 'oauth_verifier');
$result is an array with the response params => values, (*4)
$response = $oauth->get($url, $params = array(), $httpHeaders = array(), $oauthParams = array()); $response = $oauth->post($url, $body = null, $httpHeaders = array(), $oauthParams = array()); $response = $oauth->put($url, $body = null, $httpHeaders = array(), $oauthParams = array()); $response = $oauth->delete($url, $body = null, $httpHeaders = array(), $oauthParams = array());
The $response is an object with these fields, (*5)
$response->code; // HTTP Response Status Code $response->headers; // HTTP Response Headers $response->body; // Parsed response body where applicable, for example JSON responses are parsed to Objects / Associative Arrays. $response->raw_body; // Original un-parsed response body
Debug mode can be turned on via $oauth->setDebug(true). This will log both request headers and response headers and body., (*6)
A simple and easy to use OAuth1 library for PHP
MIT
oauth oauth1