所以昨天我問到如何發佈數據到表中。現在它確實給出了很好的結果,但至少需要30秒才能得出結果。我用捲曲試過,結果幾乎是瞬間的。現在我的問題是:我如何將數據從curl發佈到表中。捲曲和張貼在表
我的代碼:
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');
隨着作爲結果:
{ 「總」:5 「項」:[{ 「圖標」: 「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」:「堅定的殘忍」,「描述」:「鈍金剛箭頭......哎喲」,「當前「:{」trend「:」neutral「,」price「:222},」today「:{」trend「:」neutral「,」price「:0}},{」icon「:」http://services.runescape.com/m=itemdb_rs/4173_obj_sprite.gif?id=810「,」 「:」http://services.runescape.com/m=itemdb_rs/4173_obj_big.gif?id=810「,」id「:810,」type「:」Ammo「,」typeIcon「: 「」,「name」:「Adamant dart」,「description」:「一個致命的投擲飛鏢與堅定的小費。」,「當前」:{「trend」:「neutral」,「price」:11},「今日「:{」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「 ,「typeIcon」:「http://www.runescape.com/img/categories/Ammo」,「name」:「Adamant標槍」,「描述」:「堅韌的標槍。」,「當前」:{「趨勢」:「中立」,「價格」: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, :「Ammo」,「typeIcon」:「http://www.runescape.com/img/categories/Ammo」,「name」:「Adamant knife」,「description」:「一把精細平衡的投擲刀。」,「當前」:{「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,鍵入「:」彈藥「,」typeIcon「:」http://www.runescape.com/img/categories/Ammo「,」名稱「:」堅定的投擲斧子「 ,「描述」:「精細平衡的投擲斧」,「當前」:{「趨勢」:「中性」,「價格」:180},「今日」:{「趨勢」 :0}}]}
我試過谷歌,但因爲我關於捲曲和數組的知識是零我沒有任何進一步。
表返回值郵寄它,你只想渲染的數據表提取回來? – MajorCaiger
@MajorCaiger我不完全知道你的意思,但這是我的問題回答後昨天的結果:http://puu.sh/3UfYe.png –