So yesterday i asked about posting data into a table. Now it does give a good result but it takes at least 30 seconds to get the result. I tried it with curl and i get a result almost instant. Now my question is : How do i Post data from curl into a table.
My code :
function curl_download($Url){
// is cURL installed yet?
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}
// OK cool - then let's create a new cURL resource handle
$ch = curl_init();
// Now set some options (most are optional)
// Set URL to download
curl_setopt($ch, CURLOPT_URL, $Url);
// Set a referer
curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");
// User agent
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
// Include header in result? (0 = yes, 1 = no)
curl_setopt($ch, CURLOPT_HEADER, 0);
// Should cURL return or print out the data? (true = return, false = print)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Timeout in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// Download the given URL, and return output
$output = curl_exec($ch);
// Close the cURL resource, and free system resources
curl_close($ch);
return $output;
}
print curl_download('http://services.runescape.com/m=itemdb_rs/api/catalogue/items.json?category=1&alpha=a&page=1');
With as result :
{"total":5,"items":[{"icon":"http://services.runescape.com/m=itemdb_rs/4173_obj_sprite.gif?id=4798","icon_large":"http://services.runescape.com/m=itemdb_rs/4173_obj_big.gif?id=4798","id":4798,"type":"Ammo","typeIcon":"http://www.runescape.com/img/categories/Ammo","name":"Adamant brutal","description":"Blunt adamantite arrow...ouch","current":{"trend":"neutral","price":222},"today":{"trend":"neutral","price":0}},{"icon":"http://services.runescape.com/m=itemdb_rs/4173_obj_sprite.gif?id=810","icon_large":"http://services.runescape.com/m=itemdb_rs/4173_obj_big.gif?id=810","id":810,"type":"Ammo","typeIcon":"http://www.runescape.com/img/categories/Ammo","name":"Adamant dart","description":"A deadly throwing dart with an adamant tip.","current":{"trend":"neutral","price":11},"today":{"trend":"neutral","price":0}},{"icon":"http://services.runescape.com/m=itemdb_rs/4173_obj_sprite.gif?id=829","icon_large":"http://services.runescape.com/m=itemdb_rs/4173_obj_big.gif?id=829","id":829,"type":"Ammo","typeIcon":"http://www.runescape.com/img/categories/Ammo","name":"Adamant javelin","description":"An adamant tipped javelin.","current":{"trend":"neutral","price":64},"today":{"trend":"positive","price":"+1"}},{"icon":"http://services.runescape.com/m=itemdb_rs/4173_obj_sprite.gif?id=867","icon_large":"http://services.runescape.com/m=itemdb_rs/4173_obj_big.gif?id=867","id":867,"type":"Ammo","typeIcon":"http://www.runescape.com/img/categories/Ammo","name":"Adamant knife","description":"A finely balanced throwing knife.","current":{"trend":"neutral","price":23},"today":{"trend":"neutral","price":0}},{"icon":"http://services.runescape.com/m=itemdb_rs/4173_obj_sprite.gif?id=804","icon_large":"http://services.runescape.com/m=itemdb_rs/4173_obj_big.gif?id=804","id":804,"type":"Ammo","typeIcon":"http://www.runescape.com/img/categories/Ammo","name":"Adamant throwing axe","description":"A finely balanced throwing axe.","current":{"trend":"neutral","price":180},"today":{"trend":"neutral","price":0}}]}
I have tried google but because my knowledge about curl and array's is zero i don't got any further.