Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Set timezone Asia/Jakarta
- date_default_timezone_set('Asia/Jakarta');
- // Current date
- $date = time();
- // Fetch data from the API
- $data = json_decode(file_get_contents("https://pixels-server.pixels.xyz/cache/marketplace/listings/count"), true);
- $supply = $data['counts'];
- $prices = $data['prices'];
- // Resource itemName
- $WoodworkingItem = [
- 'itm_woodplank_04',
- 'itm_axe_03',
- 'itm_sawdust',
- 'itm_axe_02',
- 'itm_woodplank_03',
- 'itm_pickaxe_03',
- 'itm_pickaxe_02',
- 'itm_woodplank_02',
- 'itm_woodplank_01',
- 'itm_Glue',
- 'itm_woodchest_04',
- 'itm_tree_04',
- 'itm_tree_01',
- 'itm_woodenbeam',
- 'itm_woodplank_05',
- 'itm_tree_02',
- 'itm_pickaxe_04',
- 'itm_stick',
- 'itm_Wooden_Throne',
- 'itm_woodchest_05',
- 'itm_woodchest_03',
- 'itm_woodenbeam',
- 'itm_woodchest_02',
- 'itm_woodwork_kit_02',
- 'itm_tree_03',
- 'itm_woodchest_01',
- 'itm_woodwork_kit_03',
- 'itm_woodwork_kit_04',
- 'itm_pickaxe_05',
- 'itm_axe_05',
- 'itm_Wooden_Stool',
- 'itm_barn',
- 'itm_tree_05',
- 'itm_frontbench',
- 'itm_fireplace',
- 'itm_barrel01',
- 'itm_barrel03',
- 'itm_archery',
- 'itm_log_decoration2',
- 'itm_scarecrow',
- 'itm_barrel04'
- ];
- // Loop through each farming item and update its corresponding JSON file
- foreach ($WoodworkingItem as $item) {
- $jsonFile = 'data/'.$item . '.json';
- // Read existing data from JSON file
- if (file_exists($jsonFile)) {
- $farmingData = json_decode(file_get_contents($jsonFile), true);
- } else {
- $farmingData = [];
- }
- // Update the data
- $farmingData[] = [
- 'supply' => $supply[$item],
- 'price' => $prices[$item],
- 'date' => $date
- ];
- // Write the updated data back to the JSON file
- file_put_contents($jsonFile, json_encode($farmingData, JSON_PRETTY_PRINT));
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement