如何在wamp服务器中使用youtube数据api


How to use youtube data api in wamp server

我已经下载了谷歌api php客户端,并将谷歌文件夹提取到wamp服务器的根目录中。

为了访问youtube的搜索功能,我使用了github repo中的search.php。为了创建API密钥,我遵循了本教程。

在步骤5中,我选择了Public API access选项,并在create new keywindow中选择Browser key

由于我使用的是本地主机系统(wamp服务器),所以我使用这个地址http://localhost/来创建我的应用程序。在search.php.的$DEVELOPER_KEY中,新创建的API密钥被替换为REPLACE_ME

我在本地主机中打开了search.php,搜索关键字人们都很棒,但它显示了这个错误。

An client error occurred: HTTP Error: 
  Unable to connect: 'fopen(compress.zlib://https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&q=people+are+awesome&maxResults=25&key=forsecurityreasonsapikeyisremoved) 
  [<a href='function.fopen'>function.fopen</a>]: failed to open stream: operation failed'

已编辑

当我试图解决我的问题时,我在浏览器中搜索了警告中的url(使用实际密钥),它显示在错误下面

https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&amp;q=people+are+awesome&amp;maxResults=25&amp;key=forsecurityreasonsapikeyisremoved
{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "dailyLimitExceededUnreg",
    "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
    "extendedHelp": "https://code.google.com/apis/console"
   }
  ],
  "code": 403,
  "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
 }
}

看起来youtube api不起作用其他谷歌产品api起作用

www.googleapis.com/books/v1/volumes?q=Henry+David+Thoreau&amp;filter=free-ebooks&amp;key=forsecurityreasonsapike

上面的链接工作

您可以首先检查您的php.ini文件是否在上设置了此设置

allow_url_fopen = On

使用wampmanager菜单链接编辑php.ini文件,以确保您正在编辑正确的php.ini文件

wampmanager -> PHP -> php.ini