PHPackages                             jonathantorres/medium-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. jonathantorres/medium-sdk

ActiveLibrary[API Development](/categories/api)

jonathantorres/medium-sdk
=========================

Open source SDK for integrating Medium's OAuth2 API.

v0.5.1(3y ago)7933.3k↓50%13[3 issues](https://github.com/jonathantorres/medium-sdk-php/issues)1MITPHPPHP ^8.0

Since Oct 20Pushed 3y ago8 watchersCompare

[ Source](https://github.com/jonathantorres/medium-sdk-php)[ Packagist](https://packagist.org/packages/jonathantorres/medium-sdk)[ RSS](/packages/jonathantorres-medium-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (3)Versions (11)Used By (1)

Medium SDK for PHP
==================

[](#medium-sdk-for-php)

[![Tests](https://github.com/jonathantorres/medium-sdk-php/actions/workflows/tests.yml/badge.svg)](https://github.com/jonathantorres/medium-sdk-php/actions/workflows/tests.yml)[![Version](https://camo.githubusercontent.com/713544d113f382f4d45c048784d665ae94578acfb94e025e7a1b13c479a8b8ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f6e617468616e746f727265732f6d656469756d2d73646b2e737667)](https://packagist.org/packages/jonathantorres/medium-sdk)

Open source SDK for integrating [Medium](https://medium.com)'s OAuth2 API into your PHP application. Please note that Medium's API is still on an early stage and this implementation is not final. Breaking changes will happen. This SDK is unofficial. Medium's API documentation can be found [here](https://github.com/Medium/medium-api-docs).

Installation
------------

[](#installation)

```
composer require jonathantorres/medium-sdk
```

Authentication
--------------

[](#authentication)

Initialize the SDK with your client credentials:

```
    use JonathanTorres\MediumSdk\Medium;

    $credentials = [
        'client-id' => 'CLIENT-ID',
        'client-secret' => 'CLIENT-SECRET',
        'redirect-url' => 'http://example.com/callback',
        'state' => 'somesecret',
        'scopes' => 'scope1,scope2',
    ];

    $medium = new Medium($credentials);
```

You can also use the `connect` method.

```
    use JonathanTorres\MediumSdk\Medium;

    $medium = new Medium();
    $medium->connect($credentials);
```

#### Browser-based authentication

[](#browser-based-authentication)

Request the authentication url, this url will take the user to medium's authentication page. If successfull, it will return an authorization code.

```
    $authUrl = $medium->getAuthenticationUrl();
