PHP code example of melhorenvio / auth-sdk-php

1. Go to this page and download the library: Download melhorenvio/auth-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

melhorenvio / auth-sdk-php example snippets


$appData = [
    'client_id' => 'your-client-id',
    'client_secret' => 'your-client-secret',
    'redirect_uri' => 'your-redirect-uri'
];

$provider->setScopes('shipping-calculate');
header("Location: {$provider->getAuthorizationUrl()}");
exit;

$authData[] = $provider->getScopes();

$authData[] = $provider->getAccessToken($_GET['code'], $_GET['state']);

$provider->setRedirectUri('http://foo.com.br/callback');

$provider->getRedirectUri();

$newAuthData = $provider->refreshToken($authData['refresh_token']);

$newAuthData = $provider->getEndpoint();

$newAuthData = $provider->setEnvironment('production');
bash
composer 
 php
$provider = new OAuth2($appData['client_id'], $appData['client_secret'], $appData['redirect_uri']);