无法获得抽搐流的图像预览

时间:2015-04-02 17:31:29

标签: image preview twitch

我想要显示流的预览图像,但我无法使其工作。

function get_url_contents($url){
    $crl = curl_init();
    curl_setopt($crl, CURLOPT_SSL_VERIFYPEER, false);
    $timeout = 5;
    curl_setopt ($crl, CURLOPT_URL,$url);
    curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
    $ret = curl_exec($crl);
    curl_close($crl);
    return $ret;
}

$url = "https://api.twitch.tv/kraken/search/streams?limit=25&offset=0&q=Age%20of%20Empires%20II:%20The%20Conquerors ";
$json = get_url_contents($url); 
$json = json_decode($json);

foreach($json->streams as $stream) { 
    echo '<img alt="" style="float: left; width: 50px; padding-right: 7px;" src="' . $stream->channel->logo . '" />';
    echo $stream->channel->status . '<br />';
    echo $stream->channel->display_name . ' esta jugando ' . $stream->channel->game . '.<br />';
    echo '<img alt="" src="' . $stream->preview . '" /> <br />';
    echo '<a href="http://www.twitch.tv/' . $stream->channel->name . '">Ver en vivo</a>';
    echo '<hr />';
}
?>

我试图在线显示流的信息,如果我拿出这个sentece echo echo '<img alt="" src="' . $stream->preview . '" /> <br />';一切正常,但如果我放,它不起作用。并且此错误显示可捕获的致命错误:类stdClass的对象无法在第25行转换为字符串,第25行是我放的句子。

0 个答案:

没有答案