I have created a php script to get csv file first row and getting data from curl but it only show last id's data. Here is my code:
$row = 1;
if (($handle = fopen("file1.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$id = $data[0]. "<br />";
}
fclose($handle);
}
$entity = getData($id);
if($entity->success){
$websites = $entity->data->websites;
$web = $websites[0];
$website_address = $web->website_url;
echo "Website Address: $website_address <br>";
}
function getData($id){
$api_endpoint = 'url';
$data = array();
$data['api_key'] = 'abcdef';
$data['e_id'] = $id;
$url = $api_endpoint."?".http_build_query($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$obj= json_decode($output);
return $obj;
}
my csv data is like:
960626888790016
437728935677953
960626888790016
438798134112256
999649717096448
But after getting curl data from api I only get last id's data. I want all data separately.