Google Youtube API v3(使用公共API密钥)不适用于服务器,但适用于localhost [英] Google Youtube API v3 (using public API key) not working on server but it works on localhost

查看:212
本文介绍了Google Youtube API v3(使用公共API密钥)不适用于服务器,但适用于localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为这个问题苦苦挣扎了好几个星期了.我已经在 https://console.developers.google.com 中创建了公共API密钥.我的应用程序是用PHP编写的,并且使用google-api-php-client.我在Google控制台的白名单中添加了本地主机和公共服务器的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.

我的应用程序仅从某些频道获取YouTube视频列表并显示它们.在localhost上一切正常,但在服务器上会导致错误

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密钥)不适用于服务器,但适用于localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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