それで昨日、データをテーブルに投稿することについて尋ねました。現在は良い結果が得られていますが、結果を得るには少なくとも 30 秒かかります。curl で試してみたところ、ほぼ瞬時に結果が得られました。今私の質問は次のとおりです。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');
結果として:
{"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/カテゴリ/弾薬","name":"Adamant brutal","description":"鈍いアダマンタイトの矢...痛い","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":"Adamant ティップを持つ致命的な投擲ダーツ。","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":"アダマント ジャベリン","説明":"アダマント ティップド ジャベリン","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":"アダマント ナイフ","説明" :"バランスの取れた投げナイフ。","現在":{"トレンド":"ニュートラル","価格":23},"今日":{"トレンド":"ニュートラル","価格":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":"アダマント投げ斧","説明":"バランスの取れた投げ斧。","現在":{"傾向":"中立","価格":180},"今日":{"傾向":"中立" ,"価格":0}}]}
私はグーグルを試しましたが、カールと配列に関する知識がゼロであるため、それ以上は得られません。