# How to Get Channel Information

**URL:** <https://discuss.dev.twitch.com/t/how-to-get-channel-information/23523>\
**Category:** API\
**Created:** [December 20, 2019, 6:47am UTC](https://discuss.dev.twitch.com/t/how-to-get-channel-information/23523 "2019-12-20T06:47:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valezart](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/valezart/32/7545_2.png) [@Valezart](https://discuss.dev.twitch.com/u/Valezart)\
**Post date:** [December 20, 2019, 6:47am UTC](https://discuss.dev.twitch.com/t/how-to-get-channel-information/23523/1 "2019-12-20T06:47:21Z")

</div>

Hello! I am trying to get the information of one or more channels through the API. But I don’t know how it works. I have look the guide ([https://dev.twitch.tv/docs/v5/reference/channels#get-channel](https://dev.twitch.tv/docs/v5/reference/channels#get-channel)) and also looked at the forums. A few years ago I managed to do the same with the youtube API using PHP. I’m trying to get the same thing this time with Twitch channels but without success, for the moment. I don’t know how Json works.

I see the code in the guide but I do not know how to translate it into a working file online. Can I put this code on my server and execute it to get this information in a php file or something? My intention is to extract the result info data using php functions.

Reach this point:

```
curl -H 'Accept: application/vnd.twitchtv.v5+json'
-H 'Client-ID: MyChannel-ID'
-X GET 'https://api.twitch.tv/kraken/users?login=Channelname'

```

I’m triyng to put this code working on a php file or similar, and when the php is executed in my server, displays the information of the specific channel. Same info of this example: [https://dev.twitch.tv/docs/v5/reference/channels#get-channel](https://dev.twitch.tv/docs/v5/reference/channels#get-channel)

Thank you very much!

---

<div class="post-metadata">

**Author:** ![matt\_thomas](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/matt_thomas/32/710_2.png) [@matt\_thomas](https://discuss.dev.twitch.com/u/matt_thomas)\
**Post date:** [December 20, 2019, 6:57am UTC](https://discuss.dev.twitch.com/t/how-to-get-channel-information/23523/2 "2019-12-20T06:57:50Z")

</div>

If you are familiar with file\_get\_contents, you can sub it out with something like this:

```
<?php

/* file_get_contents replaced with curl function - Add this function and replace any use of file_get_contents with file_get_contents_curl */
function file_get_contents_curl($url) {
    $curlHeader = array(
        "Client-ID: xxxxxxxxxxxxxxxxxxxxxxxxxx", /* SET CLIENT ID HERE */
        "Accept: application/vnd.twitchtv.v5+json",
        "Authorization: OAuth xxxxxxxxxxxxxxxxxxxxxxxxxxx"
    );
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $curlHeader);
    $data = curl_exec($ch);
    if (!curl_errno($ch)) {
      switch ($http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE)) {
    case 200: # OK
      break;
    default:
      echo 'Unexpected HTTP code: ', $http_code, "\n";
  }
}
    curl_close($ch);
    return $data;
}

?>

```

Remove the OAuth for your purpose, it’s just there for the example.

---

<div class="post-metadata">

**Author:** ![Valezart](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/valezart/32/7545_2.png) [@Valezart](https://discuss.dev.twitch.com/u/Valezart)\
**Post date:** [December 20, 2019, 7:40am UTC](https://discuss.dev.twitch.com/t/how-to-get-channel-information/23523/3 "2019-12-20T07:40:47Z")

</div>

OMG! It worked !! Now I can continue working. Thank you very much for the help and collaboration 😃 really appreciated

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [January 19, 2020, 7:49am UTC](https://discuss.dev.twitch.com/t/how-to-get-channel-information/23523/4 "2020-01-19T07:49:59Z")

</div>

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