您好,我有一个包含以下内容的 php 文件:
当我访问 PHP 文件时图像正确显示,但是当我尝试在 HTML 模板中显示它时,它显示为带有裂缝的小 img,所以基本上说“找不到图像”
<img src="http://konvictgaming.com/status.php?channel=blindsniper47">
是我用来在 HTML 模板中显示它的东西,但它似乎不想显示,我已经尝试搜索我的具体问题几乎没有结果,尽管我确定我可能已经搜索了错误的标题
从下面的 OP 添加代码
$clientId = ''; // Register your application and get a client ID at http://www.twitch.tv/settings?section=applications
$online = 'online.png'; // Set online image here
$offline = 'offline.png'; // Set offline image here
$json_array = json_decode(file_get_contents('https://api.twitch.tv/kraken/streams/'.strtolower($channelName).'?client_id='.$clientId), true);
if ($json_array['stream'] != NULL) {
$channelTitle = $json_array['stream']['channel']['display_name'];
$streamTitle = $json_array['stream']['channel']['status'];
$currentGame = $json_array['stream']['channel']['game'];
echo "<img src='$online' />";
} else {
echo "<img src='$offline' />";
}