1. Go to this page and download the library: Download ecomphp/shopee-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/ */
ecomphp / shopee-php example snippets
use EcomPHP\Shopee\Client;
$partner_id = 'your_partner_id_here';
$partner_key = 'your_partner_key_here';
$client = new Client($partner_id, $partner_key);
$auth = $client->auth();
$redirect_uri = 'http://your-redirect-url.com';
// Returns the Shopee authentication URL instead of auto-redirecting
$authUrl = $auth->createAuthRequest($redirect_uri, true);
// Redirect user to Shopee Authorization page
header('Location: ' . $authUrl);
exit;
$authorization_code = $_GET['code'];
$shop_id = $_GET['shop_id'];
// Exchange code for Access Token & Refresh Token
$token = $auth->getToken($authorization_code, $shop_id);
$access_token = $token['access_token'];
$refresh_token = $token['refresh_token'];
// IMPORTANT: Save your access_token, refresh_token & shop_id to your database for later use