Hi there I’m currently using an API built to scrape prices out of an MMO and display them in an array.
At the moment this is my code:
<?php
ini_set('max_execution_time', 0);
$data = json_decode(file_get_contents("http://www.gw2spidy.com/api/v0.9/json/all-items/all"), true);
foreach($data as $item) {
echo '<pre>';
print_r($data);
echo '</pre>';
}
?>
This returns a MASSIVE array. I saved the html file and it’s around 35 megabytes.
It has every single price of every single item etc…
Okay so basically what I need is to search for an item such as ‘Dusk’ or by it’s itemID ‘29185’.
The prices and array keys change every hour so I’ve been trying to figure out a dynamic way of extracting this data every time but I’m stumped…
The arrays are structured like:
Array
(
[count] => 19959
[results] => Array
(
[15875] => Array
(
[data_id] => 29185
[name] => Dusk
[rarity] => 5
[restriction_level] => 80
[img] => https://dfach8bufmqqv.cloudfront.net/gw2/img/content/fabc9042.png
[type_id] => 18
[sub_type_id] => 6
[price_last_changed] => 2012-12-03 08:30:49 UTC
[max_offer_unit_price] => 3180000
[min_sale_unit_price] => 3890000
[offer_availability] => 5574
[sale_availability] => 6
[gw2db_external_id] => 63505
[sale_price_change_last_hour] => 0
[offer_price_change_last_hour] => 0
)
If anyone can point me in the right direction that would be awesome! I have searched for days and days but can’t figure it out… I bet you it’s really simple too 🙁
First of all, it would be good to know if there is a way to retrieve from the GW2 API server only the UPDATED items since your last “fetch all”. This would mean that you would only need to retrieve this entire array once, and then update the few records that are updated each time.
If you want to do it without DB you’ll just have to search for the item using a for-loop…