gpt4 book ai didi

php - PHP Twitter API 中的“无法获取本地颁发者证书”

转载 作者:太空宇宙 更新时间:2023-11-03 13:09:33 25 4
gpt4 key购买 nike

所以我需要在我正在开发的 Web 应用程序中使用 Twitter REST API,并且我已经编写了一些非常基本的 PHP 代码来测试我是否可以连接到 Twitter 服务器。不幸的是,每当我尝试执行代码时,都会出现错误:

fatal error :未捕获异常“异常”,消息为“SSL 证书问题:无法获取本地颁发者证书”

我目前在 XAMPP 3.2.2 上托管该应用程序作为测试前沿,因此它尚未正式托管在任何地方。

这是我的代码,但我的消费者 key 和 oauth token 除外,因为它们是 secret 的:

<?php

require_once("TwitterAPIExchange.php");
$url = "https://api.twitter.com/1.1/search/tweets.json";
$twitter = new TwitterAPIExchange($settings);
$requestMethod = "GET";
$getField = "?q=twitter";
$response = $twitter->setGetfield($getField)->buildOauth($url, $requestMethod)->performRequest();
echo $response;

?>

如何解决SSL证书问题?我对 SSL 不是很了解,但我需要它才能在我的 Web 应用程序中使用此 API。

正如我之前所说,我已经输入了我的 oauth 和消费者详细信息,但不是在这里,因为那是私有(private)信息

提前致谢

最佳答案

您需要设置 CURL 库以使用“CA 证书”文件(通常称为 cacert.pem)。

基本上您需要更改 php.ini ( example )。

关于php - PHP Twitter API 中的“无法获取本地颁发者证书”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39067580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com