<?php
set_time_limit(300);
ini_set('max_execution_time', 300);
error_reporting(E_ALL);
require_once('includes/load.php');
$row = getTikTokShopsAndPerformAction();
$platform = 2;
$orderProses = 0;
foreach ($row as $item) {
  $orderResponse = TiktokGetOrdersNextPage($item['access_token'], $item['shop_cipher'], 100, '');
  if (isset($orderResponse['error'])) {
    echo "Error: " . $orderResponse['error']['message'];
    die();
  }

  if ($orderResponse['data']['total_count'] == 0) {
    continue;
  }
  echo "total order " . $orderResponse['data']['total_count'] . "\n";
  $start_time = microtime(true);
  foreach ($orderResponse['data']['orders'] as $order_item) {
  }
  $end_time = microtime(true);  // Waktu selesai
  $execution_time = $end_time - $start_time;  // Waktu yang dibutuhkan untuk memproses order

  echo "Proses selesai dalam: " . $execution_time . " detik Proses Order $orderProses \n";
}
