Download the PHP package printy6/oauth1 without Composer

On this page you can find all versions of the php package printy6/oauth1. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package oauth1

OAuth 1.0 Client Library for PHP

Latest Stable Version Build Status Code Coverage Code Quality StyleCI SensioLabs Insight Total Downloads

Simple, fluent and extensible OAuth 1.0 client library for PHP.

Table of Contents

Installation

The recommended way to install this package is through Composer. Run the following command in your terminal to install this package:

Quick Start Guide

This package is flexible. You can use it to interact with any providers that implement OAuth 1.0 protocol, like Twitter.

Here's a quick example of how to use this package to interact with Twitter API: fetching the authorized user's tweets.

Configuration

You can use the static create method on Risan\OAuth1\OAuth1Factory class to easily create an instance of Risan\OAuth1\Auth1 class. It requires you to pass a configuration array with the following keys:

There are also two optional configuration that you can pass:

Signature

Each HTTP request must include a signature so that the provider can verify the authenticity of that request. This signing process is handled by the signer instance that implements the Risan\OAuth1\Signature\SignerInterface interface. This package includes two signer classes that you can use:

You can pass this signer instance as the second argument to the create static method on Risan\OAuth1\OAuth1Factory class:

If you do not pass any signer instance to the create method, the default HMAC-SHA1 signer will be used.

You can also create a custom signer class, as long as it impelements the Risan\OAuth1\Signature\SignerInterface interface.

OAuth 1.0 Flow

In order to access a protected resource, the OAuth 1.0 flow can be broken down into four steps:

Step 1: Obtaining Temporary Credentials

The very first step is to obtain the temporary credentials or mostly known as the access token. To obtain it, you need to call the requestTemporaryCredentials method on the Risan\OAuth1\OAuth1 instance:

It will return an instance of Risan\OAuth1\Credentials\TemporaryCredentials class, which later you'll use to generate an authorization URI (Step 2) and to obtain the token credentials (Step 3).

Step 2: Generate and Redirect User to Authorization URI

Once you've got the temporary credentials, the second step is to generate and redirect the user to the authorization page. This is where the user will be asked to grant their permission to your application. You need to pass the previously obtained Risan\OAuth1\Credentials\TemporaryCredentials class instance to the buildAuthorizationUri method to generate the authorization URI:

Step 3: Obtaining Token Credentials

The third step is to obtain the token credentials, or also known as the access token. Upon successful authorization, the provider will redirect the user to the defined callback URI along with at least two additional query parameters:

Along with the previously obtained temporary credentials, you'll need to pass these two query parameters to requestTokenCredentials method to obtain token credentials:

This method will return an instance of Risan\OAuth1\Credentials\TokenCredentials class, which you're going to need to access the protected resource.

Step 4: Accessing the Protected Resource

Finally, once you've got the token credentials instance, you can start making a request to the protected resource. Pass the obtained Risan\OAuth1\Credentials\TokenCredentials instance to the setTokenCredentials method before making any requests to the protected resource, or else an exception will be thrown.

The request method will return an instance of Psr\Http\Message\ResponseInterface class.

Making HTTP Request

Once you've set the obtained token credentials with the setTokenCredentials method, you can start making the HTTP request to the protected API endpoints. You can use the request method for this purpose:

This method accepts three parameters:

There are also shortcut methods for common HTTP methods:

Working with the Response

The request method will return an instance of Psr\Http\Message\ResponseInterface. You can check the returned status code with the getStatusCode method:

Or you can also get the headers on the returned response like so:

And to get the response's body, you can use the getBody method. Note that it will return a Psr\Http\Message\StreamInterface instance. To convert the StreamInterface instace into a string, you can call the getContents method or simply cast it into a string.

So if the API endpoint returns a JSON formatted response, you can covert the returned response into an associative array like this:

Built-In Providers

This package also offers some third-party providers that you can use.

Trello

Use the trello method to create an instance of OAuth1 configured for Trello.

You can get both of your API key and secret from Developer API Keys page. The base URI is set to https://api.trello.com/1/ so you can use a relative URI instead:

Tumblr

Use the tumblr method to create an instance of OAuth1 configured for Tumblr.

You need to register a Tumblr application here to get the consumer key and secret. The base URI is set to https://api.tumblr.com/v2/ so you can use a relative URI instead:

Twitter

Use the twitter method to create an instance of OAuth1 configured for Twitter.

You need to register a Twitter application here to get the consumer key and secret. The base URI is set to https://api.twitter.com/1.1/ so you can use a relative URI instead:

Upwork

Use the upwork method to create an instance of OAuth1 configured for Upwork.

You need to register a Upwork application here to get the API key and secret. The base URI is set to https://www.upwork.com/ so you can use a relative URI instead:

License

MIT © Risan Bagja Pradana


All versions of oauth1 with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
guzzlehttp/guzzle Version ~6.3|~7.2|~7.3|~7.5
guzzlehttp/psr7 Version ^1.7 || ^2.0
psr/http-message Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package printy6/oauth1 contains the following files

Loading the files please wait ....