Php 使用google自定义搜索api时未显示访问配置
以下脚本由GoogleAPI php客户端提供Php 使用google自定义搜索api时未显示访问配置,php,google-api,google-api-php-client,Php,Google Api,Google Api Php Client,以下脚本由GoogleAPI php客户端提供 <?php require_once 'src/Google_Client.php'; require_once 'src/contrib/Google_CustomsearchService.php'; session_start(); $client = new Google_Client(); $client->setApplicationName('Google CustomSearch PHP Starter Applica
<?php
require_once 'src/Google_Client.php';
require_once 'src/contrib/Google_CustomsearchService.php';
session_start();
$client = new Google_Client();
$client->setApplicationName('Google CustomSearch PHP Starter Application');
$client->setDeveloperKey('API KEY');
$search = new Google_CustomsearchService($client);
try{
$result = $search->cse->listCse('burrito', array('cx' => 'SEARCH ENGINE ID'));
print "<pre>" .print_r($result, true) . "</pre>";
}catch(Exception $e)
{
echo("<pre>".print_r($e,true)."</pre>");
}
?>
注册IPv6地址而不是IPv4当您尝试从API控制台访问尚未启用的API时,也可能发生此错误
转到并首先从那里启用API。您能告诉我如何找到IPv6地址吗?我正在使用我的本地主机。是否为127.0.0.1::1?是否正确?浏览器应用程序密钥(带引用器)API密钥:00000000引用器:0:0:0:0:0:0:1激活日期:2013年6月25日11:02上午激活人:XXX–我希望如此,但目前(2014年1月)只有您可以测试,似乎只有“旧”(“谷歌API控制台”)接口接受IPv6地址。
Google_ServiceException Object
(
[errors:protected] => Array
(
[0] => Array
(
[domain] => usageLimits
[reason] => accessNotConfigured
[message] => Access Not Configured
)
)