PHP code example of zero-to-prod / spapi-lwa

1. Go to this page and download the library: Download zero-to-prod/spapi-lwa 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/ */

    

zero-to-prod / spapi-lwa example snippets


use Zerotoprod\SpapiLwa\SpapiLwa;

$response = SpapiLwa::from('client_id','client_secret')
    ->refreshToken('refresh_token');

$access_token = $response['response']['access_token'];

use Zerotoprod\SpapiLwa\SpapiLwa;

$response = SpapiLwa::from('client_id','client_secret')
    ->clientCredentials('scope');

$access_token = $response['response']['access_token'];

use Zerotoprod\SpapiLwa\SpapiLwa;
use Zerotoprod\SpapiLwa\Support\Testing\SpapiLwaResponseFactory;

$response = SpapiLwaResponseFactory::factory()
    ->asRefreshTokenResponse()
    ->make()

SpapiLwaFake::fake($response);

SpapiLwa::from('client_id', 'client_secret')