I want to make the following API call in PHP:
https://www.googleapis.com/freebase/v1/search?indent=true&filter=%28any+type%3A%2Fcvg%2Fcomputer_videogame%29
How can I do so without using curl?
Use the PHP method: file_get_contents()
: http://us1.php.net/file_get_contents
This returns json. You should use json_decode()
and file_get_contents()
for this.
Example:
<?php
$file = file_get_contents("https://www.googleapis.com/freebase/v1/search?indent=true&filter=%28any+type%3A%2Fcvg%2Fcomputer_videogame%29");
$json = json_decode($file, true);
echo "<pre>";
print_r($json);
echo "</pre>";
?>
If it's a simple GET request, file_get_contents can do that reasonably well :
$return = file_get_contents('https://www.googleapis.com/freebase/v1/search?indent=true&filter=%28any+type%3A%2Fcvg%2Fcomputer_videogame%29');
Provided you can process the return body (depends on content-type), and do not need to process errors/special http headers/authentication.
Use "file_get_contents
" with the right configuration.