
Twitch Status Tool PHP Script
a PHP based Tool, that returns the online or offline status of a twitch.tv streamer
Overview
a PHP based class that you can use as a tool for your webapplication or website to get the current online or offline status of one or many twitch.tv streamer
Features
- very easy to use
- fast implementation: only 3 lines of code needed
- automatically gets the OAUTH token after first script runtime
- automatically refreshes the twitch OAUTH token (expires every 60 days)
Requirements
- basic PHP knowledge
- PHP Version: at least v5.6 - but v7 and higher is recommended
- Server needs to have permissions to read and write to the config-File
- cURL needs to be enabled in the php.ini / allowed on the server
Instructions
1: Register your app to obtain a client ID and client secret
https://dev.twitch.tv/console/apps/create
2: Paste your Client ID and Client Secret into the config.ini file into the according keys
3: Download the package, extract it and copy the files into the folder of your website / webapp (where the websites main index.php file is located).
If you want, use the provided "example/index.php" to learn how to use this tool first, before implementing it into your website!
For Example:
- if you want to add the livestream status on the mainpage, it often is the "index.php". Extract the files where the "index.php" is.
- if you have a page like "/streamers", go to the folder for the streamers php files and extract the files here.
If you want, you can also create a new folder (but keep in mind that you then have to change the require path).
After that, you only need to insert these three lines into your PHP File (in most cases "index.php") to get it running:
require('twitch_status_tool.php'); // change path if you created a folder $yourChannelName = new StreamerStatus("YourChannelName"); $yourChannelNameStatus = $yourChannelName->returnLiveStatus(); // result: "online" or "offline"
Additional Notes:
- Change the require Path if you created a folder.
- Change "YourChannelName" to the Twitch Channelname for which you want to get the current online / offline status.
Category | Scripts & Code / PHP Scripts / Miscellaneous |
First release | 22 November 2020 |
Last update | 24 November 2020 |
Software version | PHP 7.0, PHP 7.1, PHP 7.2, PHP 7.3, PHP 7.4, PHP 5.6 |
Tags | app, application, php, easy, site, Web, online, live, stream, offline, status, twitch |