Google Youtube API v3(使用公共 API 密钥)在服务器上不工作,但在本地主机上工作
数周以来,我一直在为这个问题而苦苦挣扎.我在 https://console.developers.google.com 中创建了公共 API 密钥.我的应用程序是用 PHP 编写的,并使用 google-api-php-client.我在谷歌控制台的白名单中添加了我的本地主机和公共服务器的 IP 地址.
I have been struggling with this problem for weeks. I have created public API key in https://console.developers.google.com. My application is written in PHP and uses google-api-php-client. I have added IP addresses of my localhost and public server in whitelist in google console.
我的应用程序仅从某些 chanell 获取 YouTube 视频列表并显示它们.在本地主机上一切正常,但在服务器上会导致错误
My application only fetches list of YouTube videos from some chanell and displays them. Everything works fine on localhost but on server it causes error
(403) Access Not Configured. Please use Google Developers Console to activate the API for your project.
奇怪的是,在服务器上启动应用程序后,它立即运行良好.但现在它坏了.
Strange is that immediatly after launching application on a server it worked fine. But now it is broken.
它在子域上也可以正常工作.... DNS 设置可能有问题吗?
It works fine on subdomain too.... Could be a problem in DNS settings?
你知道问题是什么吗?谢谢
Do you have any idea what the problem is? Thanks
修复与 cURL
有关,我真的无法解释它为什么起作用,它与 有关SSL
.
The fix had to do with cURL
, and I really can not explain why it did work, it's something related with SSL
.
基本上,你需要打开SSL
验证,通过使用
Basically, you need to turn of SSL
verification, by using
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);