Question

I am confused by the getting started docs for Freebase, where would I use my API key in this example:

<!DOCTYPE html>
<html>
<body>
<?php
include('.freebase-api-key');
$service_url = 'https://www.googleapis.com/freebase/v1/topic';
$topic_id = '/en/bob_dylan';
$params = array('key'=>$freebase_api_key);
$url = $service_url . $topic_id . '?' . http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$topic = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $topic['property']['/type/object/name']['values'][0]['value'];
?>

If I create this PHP file on my server, does the key go in this file? In the url?

Was it helpful?

Solution

Seems like your key should be $freebase_api_key. So just assign it the key value you have above the params line:

$freebase_api_key = 'blahblahblah';

The script will make an auto call for you and echo (some) output.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top