2017 © Pedro Peláez
 

library oauth1-php

A simple and easy to use OAuth1 library for PHP

image

djchen/oauth1-php

A simple and easy to use OAuth1 library for PHP

  • Tuesday, June 10, 2014
  • by djchen
  • Repository
  • 1 Watchers
  • 5 Stars
  • 597 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 4 % Grown

The README.md

# oauth1-php

oauth1-php is a super simple and basic PHP library for making OAuth 1.0 requests., (*1)

Install with Composer

{
  "require" : {
    "djchen/oauth1-php" : "dev-master"
  },
  "autoload": {
    "psr-0": {"djchen": "src"}
  }
}

Dependecies

Requires PHP 5.3+ and cURL The Unirest library is used to make HTTP requests and is included in the project., (*2)

Usage

Initializing

$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',
));

Getting a request token

$result = $oauth->requestToken('callback_url');

$result is an array with the response params => values, (*3)

Getting an access token

$result = $oauth->accessToken('oauth_token', 'oauth_token_secret', 'oauth_verifier');

$result is an array with the response params => values, (*4)

Making API calls

$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)

The Versions

10/06 2014

dev-master

9999999-dev https://github.com/djchen/oauth1-php

A simple and easy to use OAuth1 library for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

oauth oauth1