# PHP Channel info issues

**URL:** <https://discuss.dev.twitch.com/t/php-channel-info-issues/1122>\
**Category:** API\
**Created:** [October 10, 2014, 5:59pm UTC](https://discuss.dev.twitch.com/t/php-channel-info-issues/1122 "2014-10-10T17:59:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rivacom](https://avatars.discourse-cdn.com/v4/letter/r/779978/32.png) [@rivacom](https://discuss.dev.twitch.com/u/rivacom)\
**Post date:** [October 10, 2014, 5:59pm UTC](https://discuss.dev.twitch.com/t/php-channel-info-issues/1122/1 "2014-10-10T17:59:44Z")

</div>

So i’ve read a few threads on here about grabbing channel data via PHP and JSON, i’ve tried numerous differen’t methods found on these forums and other sites which all result in the same issues. Maybe someone could chime in? Here is my code.

```
    if ($result = $con->prepare('SELECT field_v
    FROM user_field_value
    WHERE field_id = "twitch"
    AND field_value != ""')) {
    
    $result->execute();
    $result->store_result();
    $result->bind_result($twitchfield);
    while($result->fetch()) {
    echo $twitchfield;
    $data = json_decode(file_get_contents('https://api.twitch.tv/kraken/streams/' . $twitchfield),true);
    var_dump($data);
    echo $data->stream->channel->display_name;
    echo $data->stream->viewers;    
}

```

So the issue I’m having is storing display\_name and viewers into a variable, so to test I just tried echoing them.

I get Notice: Trying to get property of non-object in …

However the vardump comes out fine. I’ve also tried $data[0]-\>stream-\>channel-\>display\_name with no luck as well.

What am i doing wrong? Basically I’ve been trying to redo this script since the [Justin.tv](http://Justin.tv) api was taken down, but not having a fun time yet.

---

<div class="post-metadata">

**Author:** ![Freddy](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/freddy/32/111_2.png) [@Freddy](https://discuss.dev.twitch.com/u/Freddy)\
**Post date:** [October 10, 2014, 6:13pm UTC](https://discuss.dev.twitch.com/t/php-channel-info-issues/1122/2 "2014-10-10T18:13:57Z")

</div>

iirc that should do the trick

```
echo $data['stream']['channel']['display_name'];
echo $data['stream']['viewers'];

```

Edit: also see [Twitch API: Trying To Return No of Viewers [PHP]](https://discuss.dev.twitch.tv/t/twitch-api-trying-to-return-no-of-viewers-php/1075)
