您好,我正在尝试使用 google+ Rest API 获取个人资料数据,但我收到此错误:
致命错误:未捕获异常“GuzzleHttp \ Ring \ Exception \ RingException”,消息为“cURL错误60:请参阅C:\ wamp中的http://curl.haxx.se/libcurl/c/libcurl-errors.html” \www\plus3 endor\guzzlehttp\guzzle\src\Exception\RequestException.php 第 51 行
目前我正在本地主机上工作。我已经尝试了一切,包括 安装composer、curl...等。 不知道我做错了什么。为什么我无法从个人资料中获取数据。
这是代码:
<?php
include_once __DIR__ . '/../vendor/autoload.php';
include_once "templates/base.php";
session_start();
$client = new Google_Client();
$client = new Google_Client();
$client->setApplicationName("Google+ PHP Starter Application");
// credentials are intentionally not disclosed but they are correct.
$client->setClientId('XXXXXX');
$client->setClientSecret('XXXXXXX');
$client->setRedirectUri('http://localhost/....');
$client->setDeveloperKey('XXXXX');
$plus = new Google_Service_Plus($client);
//Everything works fine before this line...as soon as i write the line
//below to fetch results with name brett...it throws me an error.
$results = $plus->people->search('brett');
?>
<!doctype html>
<html>
<head><link rel='stylesheet' href='style.css' /></head>
<body>
<header><h1>Google+ Sample App</h1></header>
</body>
</html>
可能有点晚了,但对于将来浏览这些页面的人来说:
检查 php.ini 文件中的“curl.cainfo”选项。指定证书的绝对路径(您可以在以下位置下载:http://curl.haxx.se/ca/cacert.pem)。 通过删除行开头的分号来激活该选项。重新启动 Apache 服务器就可以了。
如果您的操作系统有centos或Fedora,则必须允许Httpd_can_network_connect连接。 默认情况下,所有访问 httpd(nginx-apache-...) 都是禁用的。
setsebool httpd_can_network_connect 1