Google Youtube API v3(使用公共 API 密钥)在服务器上不工作,但在本地主机上工作 [英] Google Youtube API v3 (using public API key) not working on server but it works on localhost

查看:37
本文介绍了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);

这篇关于Google Youtube API v3(使用公共 API 密钥)在服务器上不工作,但在本地主机上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆