CrunchBase API から企業リストのデータを取得し、そのデータをデータベースの選択テーブルに追加しようとしています。どこから始めればいいのか本当にわかりません。私はcURLを見てきました。
私が今いる場所:
$url = "http://api.crunchbase.com/v/1/company/audible-coffee.js?api_key=API_KEY&callback=?";
$data = get_data($url);
// Note: ideally you should use DOM manipulation to inject the <base>
// tag inside the <head> section
$data = str_replace("<head>", "<head><base href=\"$url\">", $data);
echo $data;
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_close($ch);
return $data;
}
今すぐ解析してから、データをデータベースに保存することになっていると思います。
データの解析に関するコードを見つけるための私の努力は次のとおりです。
$json_string = '<url.json>';
$jsondata = file_get_contents($json_string);
$obj = json_decode($jsondata, true);
print_r($obj['Result']);
残念ながら、私は自分が何をしているのかわからないので、何を変更するか、またはここからどこへ行くべきかについての意見をいただければ幸いです。