I am looking to pull data for a list of companies from CrunchBase API, then add that data into select tables in a database. I really don't know where to start. I have been looking at cURL.
Where I am at right now:
$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;
}
I think I am supposed to parse it now, then store the data in the database.
My efforts to find code on parsing the data is the following:
$json_string = '<url.json>';
$jsondata = file_get_contents($json_string);
$obj = json_decode($jsondata, true);
print_r($obj['Result']);
Unfortunately, I don't know what I'm doing so any input on what to change or where to go from here will be very much appreciated.