I currently have a db table filled with organisation numbers [1,002 million rows].
Now, what im trying to do is fetch the phone number of the organisation from a remote website API. I've got this working, but just after 30-50 or so requests to the API, i dont see any new changes to the table im inserting the phone numbers into. I've still got 1 million++ rows to fetch the phone number from, but i cant seem to get further than a small amount of rows.
Thanks in advance for the help.
I dont know if this is gonna help, but here is the code im using to do this.
// Remove timeout limit
// This is going to take alot of time!
set_time_limit(0);
// Initialize...
include $_SERVER['DOCUMENT_ROOT'] . '/core/Init.php';
// Profiles
$url = 'http://finnrett.no/API/business/get/quickresults?q=';
$profile_url = 'http://finnrett.no/API/business/get/profile?id=';
// Select names
$sql = 'SELECT organisasjonsnummer FROM brreg ORDER BY id LIMIT 10000';
$result = $Dbh -> query($sql, []);
// Each name
foreach ($result as $orgnr) {
// Pre for output explananation
echo'<pre>';
// Grab json from quick results url
$bedrift = json_decode(file_get_contents($url.$orgnr['organisasjonsnummer']));
$ID = get_object_vars($bedrift[0])['ID'];
$profile = json_decode(file_get_contents($profile_url.$ID));
$CONTACT = get_object_vars($profile);
$number = $CONTACT['contact'] ? $CONTACT['contact']: '0';
$sql = 'INSERT INTO profiles (orgnr, telefon) VALUES (:orgnr, :telefon)';
$args = ['orgnr' => $orgnr['organisasjonsnummer'], 'telefon' => $number];
if (!$Dbh -> query($sql, $args)) {
echo 'Sjekk opp org: ' . $orgnr['organisasjonsnummer'] . ' fordi her skjedde det noe galt.';
}
}
Looks like i solved it by choosing curl instead of file_get_contents.