2

I have a curl script that I have calling Rotten Tomatoes. Every time I run it, even in a for loop from 1 to 10, it runs infinitely. The only way to stop it is by restarting the server, the page continues to call the rotten tomatoes site until the server goes down. The curl script works for other APIs so it should work for this one. Here it is, any idea?: For the $temp_movie, that gets its value and works properly.

$ch = curl_init();
$api_link = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=****&q=".$temp_movie."&page_limit=1";
echo $api_link."<br>";
curl_setopt($ch, CURLOPT_URL, $api_link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
$content = trim(curl_exec($ch));
curl_close($ch);
$rottentomatoes = json_decode($content, true);
MrLore
  • 3,759
  • 2
  • 28
  • 36
Daniel Fein
  • 317
  • 1
  • 6
  • 18

1 Answers1

1

I have no idea why this worked but like I said, the curl script worked for other APIs, so I tried copy and pasting the same curl code (again) and trying again. Some reason this works? Is there any difference that I'm just not seeing?:

$ch = curl_init();
$api_link = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=****&q=".$temp_movie."&page_limit=1";
curl_setopt($ch, CURLOPT_URL, $api_link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
$content = trim(curl_exec($ch));
curl_close($ch);
$rottentomatoes = json_decode($content, true);
MrLore
  • 3,759
  • 2
  • 28
  • 36
Daniel Fein
  • 317
  • 1
  • 6
  • 18