0

how can I implement my client-ID in my request to the twitch API servers via PHP?

This is my current code:

$clientid="xxxxxxxxx";
function is_channel_live($channel)
{
$request = json_decode( @file_get_contents( 'https://api.twitch.tv/kraken/streams/' . $channel ) );
return ( ! is_null( $request->stream ) ) ? TRUE : FALSE;
}
$chan = "shroud";
if (is_channel_live($chan)==true)
echo "Live!!";

else
echo "Offline..";

How would I actually implement the client ID in the request?

May also note that I am very new to the twitch API..

Jonathan
  • 685
  • 1
  • 10
  • 30
  • [Have you seen this?](https://dev.twitch.tv/docs/v5/guides/authentication/) – Peter Rakmanyi Aug 05 '17 at 21:17
  • @PeterRakmanyi If I'm not mistaken that's for authorizing twitch users for an application etc. That's not what I need. All I need is the clientID to be sent during the request. What I've read this is the way to go, at least. Like having the client ID in the php header or something like that I guess – Jonathan Aug 05 '17 at 21:27
  • 1
    Client-id is set as a request header. Are you asking how to set a header? See: https://stackoverflow.com/questions/3032643/php-get-request-sending-headers – JBC Aug 08 '17 at 13:43

0 Answers0