PHP code example of xgerhard / nbheaders

1. Go to this page and download the library: Download xgerhard/nbheaders library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xgerhard / nbheaders example snippets




$nbheaders = new xgerhard\nbheaders\nbheaders;

if($nbheaders->isNightbotRequest())
    echo 'Platform: '. $nbheaders->getProvider() .' | User: '. http_build_query($nbheaders->getUser(), '', ', ') .' | Channel: '. http_build_query($nbheaders->getChannel(), '', ', ') .' | Timer: '. ($nbheaders->isTimer() ? 'Yes' : 'No') .' | Moderator: '. ( $nbheaders->isUserModerator() ? 'Yes' : 'No');
else
    echo 'Not a Nightbot request';

// Available functions:
// getUser() retrieve user info who called the command
// getChannel() retrieve channel info where the command was used
// getResponseUrl() retrieve response url to use with Nightbot API
// getProvider() retrieve the provider e.g. twitch, youtube, discord
// isNightbotRequest() checks if the command was called by Nightbot
// isTimer() checks if the command is called from a timer (Returns false if its called by a user)
// isUserModerator() checks if the user calling the command is a moderator
!commands add !nb $(urlfetch https://2g.be/twitch/Nightbot/headers.php)