I need to parse JSON
from multiple URLs. Here is the way that I'm following:
<?php
//call
$url1 = file_get_contents("https://www.url1.com");
$url2 = file_get_contents("https://www.url2.com");
$url3 = file_get_contents("https://www.url3.com");
$url4 = file_get_contents("https://www.url4.com");
$url5 = file_get_contents("https://www.url5.com");
//parse
$decode1 = json_decode($url1, true);
$decode2 = json_decode($url2, true);
$decode3 = json_decode($url3, true);
$decode4 = json_decode($url4, true);
$decode5 = json_decode($url5, true);
//echo
if (is_array($decode1)) {
foreach ($decode1 as $key => $value) {
if (is_array($value) && isset($value['price'])) {
$price = $value['price'];
echo '<span><b>' . $price . '</b><span>';
}
}
}
?>
This way causes slowness in the page openings. On the other hand, I get these errors:
Warning: file_get_contents(https://www.url1.com): failed to open stream: Redirection limit reached, aborting in /home/directory/public_html/file.php on line 12
Warning: file_get_contents(https://www.url2.com): failed to open stream: Redirection limit reached, aborting in /home/directory/public_html/file.php on line 13
etc.
How can I fix the redirection limit reached
warning?