PHP code example of isckosta / laravel-tiktok-shop
1. Go to this page and download the library: Download isckosta/laravel-tiktok-shop 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/ */
isckosta / laravel-tiktok-shop example snippets
/tiktok/authorize -> TikTokShopAuthController@redirect
/tiktok/callback -> TikTokShopAuthController@callback
/webhooks/tiktok-shop -> TikTokWebhookController@handle
'enable_default_routes' => false,
use App\Http\Controllers\TikTokOAuthController;
use App\Http\Controllers\TikTokWebhookController;
Route::get('/tiktok/authorize', [TikTokOAuthController::class, 'redirect']);
Route::get('/tiktok/callback', [TikTokOAuthController::class, 'callback']);
Route::post('/webhooks/tiktok', [TikTokWebhookController::class, 'handle']);
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use TikTokShop\Facades\TikTokShop;
class TikTokOAuthController extends Controller
{
public function redirect()
{
$url = TikTokShop::oauth()->getAuthorizationUrl();
return redirect()->away($url);
}
public function callback(Request $request)
{
$code = $request->query('code');
$tokens = TikTokShop::oauth()->getAccessToken($code);
// Salvar tokens no banco
// TikTokCredential::create($tokens);
return response()->json($tokens);
}
}
$client = TikTokShop::connection('default');
$response = $client->products()->search([
'page_size' => 20,
]);
$response = TikTokShop::connection('default')->products()->create($payload);
$response = TikTokShop::connection('default')->orders()->list([
'page_size' => 10,
]);
bash
php artisan vendor:publish --tag="tiktokshop-config"
bash
php artisan vendor:publish --tag="tiktokshop-migrations"
bash
php artisan vendor:publish --tag="tiktokshop-controllers"
bash
php artisan vendor:publish --tag="tiktokshop-routes"
bash
php artisan vendor:publish --tag="tiktokshop-controllers"
bash
php artisan tiktokshop:authorize
bash
php artisan tiktokshop:sync-products
bash
php artisan vendor:publish --tag="tiktokshop-config"
bash
php artisan vendor:publish --tag="tiktokshop-migrations"
bash
php artisan vendor:publish --tag="tiktokshop-controllers"
bash
php artisan vendor:publish --tag="tiktokshop-routes"
bash
php artisan test