PHP code example of dvicklund / ebay-oauth-php-client

1. Go to this page and download the library: Download dvicklund/ebay-oauth-php-client 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/ */

    

dvicklund / ebay-oauth-php-client example snippets


use EbayOauthToken\EbayOauthToken;

$ebayAuthToken = new EbayOauthToken([
    'env' => '<SANDBOX|PRODUCTION>', // If not provided, env defaults to PRODUCTION
    'clientId' => '<your_client_id>',
    'clientSecret' => '<your_client_secret>',
    'redirectUri' => '<redirect uri>'
]);

$token = $ebayAuthToken->getApplicationToken('PRODUCTION');
print($token);

$authUrl = $ebayAuthToken->generateUserAuthorizationUrl('PRODUCTION', $scopes);
print($authUrl);

$options = [ 'state' => 'custom-state-value', 'prompt' => 'login' ];
$authUrl = $ebayAuthToken->generateUserAuthorizationUrl('PRODUCTION', $scopes, $options);
print($authUrl);

$accessToken = $ebayAuthToken->exchangeCodeForAccessToken('PRODUCTION', $code);
print($accessToken);

$accessToken = $ebayAuthToken->getAccessToken('PRODUCTION', $refreshToken, $scopes);
print($accessToken);

use EbayOauthToken\EbayOauthToken;

$ebayAuthToken = new EbayOauthToken([
    'filePath' => 'demo/eBayJson.json' // input file path.
]);

$ebayAuthToken = new EbayOauthToken([
    'clientId' => '<your_client_id>',
    'clientSecret' => '<your_client_secret>',
    'redirectUri' => '<redirect_uri_name>'
]);
bash
$ composer