PHP-在哪里使用freebase API密钥?

PHP-在哪里使用freebase API密钥?,php,freebase,api-key,Php,Freebase,Api Key,我对Freebase的入门文档感到困惑,在本例中,我将在何处使用API密钥: <!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'=>$freeb

我对Freebase的入门文档感到困惑,在本例中,我将在何处使用API密钥:

<!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'];
?>


如果我在我的服务器上创建这个PHP文件,那么密钥是否会进入这个文件?在url中?

似乎您的密钥应该是
$freebase\u api\u key
。因此,只需将参数行上方的键值指定给它:

$freebase_api_key = 'blahblahblah';

脚本将为您自动调用并回显(部分)输出。

您想做什么,或者什么工作不符合您的要求?这是本页的一个示例:它应该“检索Freebase主题并显示主题名称”如果我的api密钥是blahblahblah,并且我将php页面放在example.com/freebase.php上,我尝试创建url http:但是我没有得到任何api在
https://www.googleapis.com/freebase/v1/topic
因此您需要使用
https://www.googleapis.com/freebase/v1/topic?key=blahblahblah