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.

我正在尝试从twitch API获取通道的数据,并且...由于某种原因它总是失败:X 这是我总是得到的错误: p>

 遇到PHP错误
 
Severity:Warning 
 
Message:file_get_contents(https://api.twitch.tv/  kraken / streams / diesel1521?client_id = ******):无法打开流:HTTP请求失败!  HTTP / 1.1 422不可处理的实体
 
文件名:page / home.php 
 
Line编号:7 
  code>  pre> 
 
 

我将为您提供一个实例: http://91.139.176.200/ code> Page code: p>

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

使用的唯一变量将始终从数据库返回流光的显示名称。使用CodeIgniter,最新版本。如果有人问,我有openssl,http和https启用。 p> div>

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.