PHP code example of nda666 / tokopedia-php

1. Go to this page and download the library: Download nda666/tokopedia-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/ */

    

nda666 / tokopedia-php example snippets


$tokopedia = new \TokopediaPhp\Tokopedia([
                'clientId' => env('TOKOPEDIA_CLIENT_ID'),
                'fsId' => env('TOKOPEDIA_FS_ID'),
                'clientSecret' => env('TOKOPEDIA_CLIENT_SECRET')
            ]);
$product = $tokopedia->product()->getProducts([
            'page' => $page,
            'per_page' => 50,
            'sort' => 1,
            'shop_id' => $shopId
        ])->getData();

echo json_encode($product);
// {
//   "header": {
//     "process_time": 5.871520385,
//     "messages": "Your request has been processed successfully"
//   },
//   "data": [
//     {
//       "basic": {
//         "productID": 15245228,
//         "shopID": 480829,
//         "status": 1,
//         "Name": "hxh wallpaper best la zzzz",
//         "condition": 1,
//         "childCategoryID": 1828,
//         "shortDesc": "Best wallpaper for hxh"
//       },
//       ...
//     }
//   ]
// }
bash
composer