For a class project, we are supposed to pull data from another website. I picked pulling games similar to a given game from GiantBomb.com (credits are given to them on my script)
// $gameLink = "/call-of-duty-black-ops/61-26423/";
$html = file_get_contents("http://www.giantbomb.com" . urlencode($gameLink) . "games_similar/");
echo $html;
This returns nothing.
However, if $gameLink is manually typed:
$html = file_get_contents("http://www.giantbomb.com/call-of-duty-black-ops/61-26423/games_similar/");
echo $html;
Now, it will properly return a result. What's wrong with my code? I tried performing urlencode()
on the entire link and not just the $gameLink variable but it still fails. Does anyone have any suggestions?
You are only required to urlencode links embedded in html. Don't urlencode links passed to file_get_contents().