I'm trying to loop it. But when executing this script:
for ( $page_number = 1; $page_number <= $pages_count ; $page_number++ )
{
$url = $this->makeURL( $limit, $category->getSources()[0]->getSourceId(), $subCat->getSources()[0]->getSourceId() );
echo $url."</br>"; // Returns the correct URL
$json = json_decode( file_get_contents( $url ) );
echo "<pre>";
print_r( $json ); //Only return the proper date the first time. Then its always the same whatever the url
echo "</pre>";
//$this->insert( $json, $subCat );
$limit = $limit + 10;
}
The reponse I get in the file_get_contents()
doesn't match the url called (the parameters changes during the loop of course, its like a pagination, but I always get the first page for no reason.). Even if the URL is ok, it doesn't seem to call this page and always returns the same results. But when I copy and paste the URL from the what I get in the echo to my browser search/url bar, I get the right results.
I have the feeling I'm missing something with file_get_contents()
maybe to clear the previous call or something.
EDIT: This is the makeURL()
public function makeURL( $limit, $mainCat, $subCat )
{
$pagi_start = $limit;
$url = "http://some.api/V3/event_api/getEvents.php?"
. "&cityId=" . "39"
. "&subcat=" . $subCat
. "&cat=" . $mainCat
. "&link=" . "enable"
. "&tags=" . "enable"
. "&strip_html=". "name,description"
. "&moreInfo=" . "popularity,fallbackimage,artistdesc"
. "&tz=" . "America/Los_ Angeles"
. "&limit=" . $pagi_start.",10";
return $url;
}