douzuqin3467 2013-12-29 21:57
浏览 247
已采纳

PHP:file_get_contents():无法打开流:HTTP请求失败 - HTTP / 1.1 422无法处理的实体

I'm trying to get channel's data from the twitch API and... for some reason it always fails :X This is the error I always get:

A PHP Error was encountered

Severity: Warning

Message: file_get_contents(https://api.twitch.tv/kraken/streams/diesel1521?client_id=******): failed to open stream: HTTP request failed! HTTP/1.1 422 Unprocessable Entity

Filename: page/home.php

Line Number: 7

I will give you a live example: http://91.139.176.200/ Page code:

$channel = json_decode(file_get_contents('https://api.twitch.tv/kraken/streams/'.strtolower($this->streamer->getStreamerDisplayName($this->_id, true).'?client_id=******'), true);

the only variable used will always return a streamer's display name from the database. Using CodeIgniter, latest version. If anyone is asking, I have openssl, http and https enabled.

  • 写回答

1条回答 默认 最新

  • dougudu3564 2013-12-29 22:02
    关注

    Open the url in a browser and look at the response:

    {"error":"Unprocessable Entity","status":422,"message":"Channel 'diesel1521' is unavailable"}
    

    The error comes from the fact that the channel you are requesting is unavailable.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料