Getting Streams

This is my first time using a api,and im trying to learn , so im using this example https://github.com/justintv/Twitch-API/blob/master/RESTful-Integration-Guide.md , and is supose to show the name of the top streamer , but only show name in the page . here is my code, i dont know what im doing wrong .

<?php function get_url_contents($url){ $crl = curl_init(); $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; } $streams = json_decode(get_url_contents("https://api.twitch.tv/kraken/streams")); echo "name" . $streams->streams[0]->channel->name; ?>

This code runs fine and prints the name of the first returned streamer from the api call to /streams. What issue are you getting?

Its only display " name " (without quotes) in the screen . I cant post images

It prints the concatenation of ‘name’ and the username of the first streamer object.
If this is not what you are seeing, you may be running an out-of-date version of PHP.

What php’s version do i need to work with the api?

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.