我想从本地主机连接到google API,但继续接收异常(密钥已更改 - 在下面的文本中)。在ZF2/PHP上设置Google API - 无法连接到服务器
Warning: file_get_contents(compress.zlib://https://www.googleapis.com/books/v1/volumes?q=Henry+David+Thoreau&filter=free-ebooks&key=bItatTTTTT7amAHYSaROTTTTTbtttuuuuuuuu) [function.file-get-contents]: failed to open stream: operation failed in C:\zendProject\zf2\vendor\google\apiclient\src\Google\IO\Stream.php on line 115
我用我的浏览器的代码从API指南来直中记载:
$client = new \Google_Client();
$client->setApplicationName("rent");
$service = new \Google_Service_Books($client);
$optParams = array('filter' => 'free-ebooks');
$results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
我觉得我的问题涉及到的配置文件,而事实上我工作过的本地主机开发服务器。
'Google_Auth_OAuth2' => array(
'application_name' => 'www.example.com',
'client_id' => '4498xxxxx061-3333xxxx9pjcpkbqhoxxxxxxxxxxx.apps.googleusercontent.com',
'client_secret' => '8xxxxxxxxx333xxxxxxxxx',
'redirect_uri' => 'http://localhost',
'developer_key' => 'AxxxxxxzBjpxxxxxaxxxxxxZxxx1xxxxx',
在新的开发者控制台,我已经创造了该项目新的客户端ID和插入“CLIENT_ID”,“Client_secret”等
我也启用了压光机和图书相关的API 。
我已经在我找到的谷歌字体的URL上测试了我的API密钥 - 所以我确定我拥有正确的开发人员密钥。
我怀疑这个问题可能是在uri字段中的本地主机周围,我需要在这里放什么?
有谁知道我做错了什么。
更新:我发现建议得到HTTP响应代码here一个帖子:
来自服务器的响应是304 - 不知道这是否有助于
UPDATE: @Carlos卢布 - 是正确的我正在使用不正确的版本。万一有其他人遇到这个问题 - 谷歌网站上的作曲家信息似乎是不正确的。
我之前使用过的“google/apiclient”:“1.0。”这个出现在google文档中。我现在试过“谷歌/ apiclient”:“1.”,这似乎已经解决了这个问题。
你是对的 - 我已经更新了这篇文章,注意到Composer对我的改动。鉴于我削减和张贴,我假设我有最新的材料。非常感谢! –