Plugin Directory

Changeset 2527323


Ignore:
Timestamp:
05/06/2021 02:56:01 PM (5 years ago)
Author:
Ryan Bayne
Message:

Improvements to webhooks system

Location:
twitchpress
Files:
429 added
34 edited

Legend:

Unmodified
Added
Removed
  • twitchpress/trunk/functions.php

    r2496316 r2527323  
    1212include_once( plugin_basename( 'includes/functions/functions.twitchpress-get.php' ) );               
    1313include_once( plugin_basename( 'includes/functions/functions.twitchpress-database.php' ) );               
     14include_once( plugin_basename( 'systems/webhooks/functions.twitchpress-webhooks.php' ) );               
    1415
    1516function twitchpress_is_backend_login(){
     
    839840    return TwitchPress_Object_Registry::update_var( 'mainchannelauth', 'main_channels_postid', $expires_in );
    840841}             
     842
    841843######################################################################
    842844#                                                                    #
     
    12141216    return $url;       
    12151217}
    1216 
    1217 
    12181218
    12191219/**
     
    14741474*/
    14751475function twitchpress_validate_token( $token ) {     
    1476     if( strlen ( $token ) !== 30  ) {         twitchpress_var_dump_safer();
     1476    if( strlen ( $token ) !== 30  ) {         
    14771477        return false;
    14781478    }           
    14791479   
    1480     if( !ctype_alnum( $token ) ) {         twitchpress_var_dump_safer();
     1480    if( !ctype_alnum( $token ) ) {         
    14811481        return false;
    14821482    }
     
    25232523    // Cancelled
    25242524    if( $local_sub_array && !$twitch_sub_array ) {
     2525       
    25252526        TwitchPress_Admin_Notices::add_wordpress_notice( 'usersubsyncnosubresponse', 'warning', false,
    25262527        __( 'Subscription Ended', 'twitchpress' ),
     
    25362537
    25372538    // No recent subscription...
    2538     if( !$local_sub_array && !$twitch_sub_array || !isset( $twitch_sub_array->tier ) ) {
     2539    if( !$local_sub_array && !$twitch_sub_array || !isset( $twitch_sub_array->tier ) ) { 
    25392540        TwitchPress_Admin_Notices::add_wordpress_notice( 'usersubsyncnosubresponse', 'info', false,
    25402541        __( 'Not Subscribing', 'twitchpress' ),
     
    25482549   
    25492550    // First time subscription sync...
    2550     if( !$local_sub_array && $twitch_sub_array && isset( $twitch_sub_array['tier'] ) ) {
     2551    if( !$local_sub_array && $twitch_sub_array && isset( $twitch_sub_array['tier'] ) ) { 
    25512552        TwitchPress_Admin_Notices::add_wordpress_notice( 'usersubsyncnosubresponse', 'success', false,
    25522553        __( 'New Subscriber', 'twitchpress' ),
     
    26272628    var_dump( 'PEAK: ', memory_get_peak_usage(), '<br>' );  # DO NOT REMOVE #     
    26282629}
     2630
     2631function twitchpress_send_to_console( $debug_output ) {
     2632
     2633    $cleaned_string = '';
     2634    if (!is_string($debug_output))
     2635        $debug_output = print_r($debug_output,true);
     2636
     2637      $str_len = strlen($debug_output);
     2638      for($i = 0; $i < $str_len; $i++) {
     2639            $cleaned_string .= '\\x' . sprintf('%02x', ord(substr($debug_output, $i, 1)));
     2640      }
     2641    $javascript_ouput = "<script>console.log('Debug Info: " .$cleaned_string. "');</script>";
     2642    echo $javascript_ouput;
     2643}
     2644
     2645
     2646function twitchpress_get_main_channels_team_id() {
     2647    return get_option( 'twitchpress_main_channel_team_id' );
     2648}
     2649
     2650function twitchpress_update_main_channels_team_id( $twitch_team_id ) {
     2651    return update_option( 'twitchpress_main_channel_team_id', $twitch_team_id );
     2652}
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-data-views.php

    r2477212 r2527323  
    7474                ),*/
    7575            )
    76         );       
    77          
    78         // API Results (Raw curl response)
    79         $tabviews['apioutcomes_list_tables'] = array(
    80             'title'  => __( 'API Outcomes', 'twitchpress' ),
    81             'datatabviews' => array(
    82                 "apioutcomes" => array(
    83                     'title'       => __( 'All Data', 'twitchpress' ),
    84                     'description' => '',
    85                     'hide_title'  => true,
    86                     'callback'    => array( __CLASS__, 'get_maintabview' )
    87                 )
    88             )
    89         );     
     76        );             
    9077           
    9178        // API Errors
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-help.php

    r2494470 r2527323  
    176176            'content'   => '',
    177177            'callback'  => array( $this, 'faq' ),
    178         ) );   
    179                
    180         $screen->add_help_tab( array(
    181             'id'        => 'twitchpress_bot_status_tab',
    182             'title'     => __( 'Twitch Bot Status', 'twitchpress' ),
    183             'content'   => '',
    184             'callback'  => array( $this, 'bot_status' ),
    185         ) );   
     178        ) );     
    186179                   
    187180        $screen->add_help_tab( array(
     
    333326        <?php
    334327    }
    335    
    336     public function bot_status() {   
    337         $set_app_status = twitchpress_get_app_status();
    338         $output = '';
    339        
    340         // Ensure the Twitch API application has been setup...
    341         if( $set_app_status[0] !== 1 ) {
    342             echo '<h3>' . __( 'Welcome to TwitchPress', 'twitchpress' ) . '</h3>';
    343             echo $set_app_status[1];             
    344             echo '<p><a href="' . admin_url( 'index.php?page=twitchpress-setup' ) . '" class="button button-primary">' . __( 'Setup wizard', 'twitchpress' ) . '</a></p>';           
    345             return;   
    346         }
    347        
    348         // Check cache...
    349         $cache = get_transient( 'twitchpresshelptabbotstatus' );
    350         if( $cache )
    351         {
    352             _e( '<p>You are viewing cached data that is up to 120 seconds old. Refresh again soon to get the latest data.</p>', 'twitchpress' );
    353             print $cache;
    354             return;
    355         }
    356         else
    357         {
    358             // No existing cache found, so test Twitch API, generate output, cache output, output output!
    359             _e( '<p>You are viewing real-time data on this request (not cached). The data will be cached for 120 seconds.</p>', 'twitchpress' ); 
    360         } 
    361        
    362         // Avoid making these requests for every admin page request.
    363         set_transient( 'twitchpresshelptabappstatus', $output, 120 );
    364 
    365         print $output;           
    366     }
    367      
     328         
    368329    /**
    369330    * Displays Twitch application status.
     
    517478       
    518479        ob_start();
    519         echo '<h3>Testing Area</h3>';
    520         echo '<p>' . __( 'Do not test on live sites please. Some features are WIP.', 'twitchpress' ) . '</p>';
     480        echo '<h3>Test New Features</h3>';
     481        echo '<p>' . __( 'Do not test on live sites.', 'twitchpress' ) . '</p>';
    521482       
    522483        // New Test
     
    547508        ob_start();
    548509        echo '<h3>Development Area</h3>';
    549         echo '<p>' . __( 'This tab helps everyone find exactly what is being worked on in the project. Developers should check the source-code in this tab
    550         and the testing tab for clues on what is coming soon. Please test shortcodes and links here but do not feedback faults.', 'twitchpress' ) . '</p>';
     510        echo '<p>' . __( 'Do not use these features on live sites. Feel free to test features
     511        but do not feedback faults.', 'twitchpress' ) . '</p>';
    551512       
    552513        // New Test
     
    555516        echo '<p>[twitchpress_raffle_entry_button]Gated content goes here.[/twitchpress_raffle_entry_button]</p>';
    556517       
    557         ob_end_flush();
    558 
    559         ########################################################################
    560         #                                                                      #
    561         #                               WEBHOOKS                               #
    562         #                                                                      #
    563         ########################################################################
    564         /*
    565         $test1 = 1;
    566         $test2 = 0;
    567         $test3 = 0;
    568        
    569         $callback = 'http://local # IGNORE # host/twitchpress/branches/beta/wp-admin/admin.php';
    570         $topic    = 'https://api.twitch.tv/helix/streams?user_id=120841817';
    571        
    572         if( $test1 )
    573         {
    574             $twitch_webhooks = new TwitchPress_Twitch_Webhooks();
    575            
    576             $twitch_webhooks->callback = $callback;
    577             $twitch_webhooks->mode     = 'subscribe';
    578             $twitch_webhooks->topic    = $topic;
    579             $twitch_webhooks->secret   = null;
    580            
    581             $result = $twitch_webhooks->users_follows( 0, 1, '120841817', null );
    582            
    583         }
    584        
    585         if( $test2 )
    586         {
    587             $curl = new WP_Http_Curl();
    588             $curl_version_object = curl_version();
    589 
    590             $result = $curl->request(
    591                 'https://api.twitch.tv/helix/webhooks/hub',
    592                 array(
    593                     'method'     => 'POST',
    594                     'user-agent' => 'curl/' . $curl_version_object['version'],
    595                     'stream'     => false,
    596                     'filename'   => false,
    597                     'decompress' => false,
    598                     'headers' => array(
    599                         'content-type'      => 'application/x-www-form-urlencoded',
    600                         'client_id'         => twitchpress_get_app_id(),
    601                     ),
    602                     'body' => array (
    603                         'hub.callback'      => 'http://local # IGNORE # host/twitchpress/branches/beta/wp-admin/admin.php',
    604                         'hub.mode'          => 'subscribe',
    605                         'hub.topic'         => 'https://api.twitch.tv/helix/users/follows',
    606                         'hub.lease_seconds' => 0,
    607                         'hub.secret'        => null,
    608                         'first'             => 1,
    609                         'from_id'           => 120841817,
    610                         'to_id'             => null
    611                     )
    612                 )
    613             );
    614         }
    615        
    616         if( $test3 )
    617         {
    618             $http = new WP_Http();
    619             $curl_version_object = curl_version();
    620 
    621             $body = json_encode( array (
    622                         'hub.callback'      => $callback,
    623                         'hub.mode'          => 'subscribe',
    624                         'hub.topic'         => $topic,
    625                         'hub.lease_seconds' => 0,
    626                         'hub.secret'        => null,
    627                         'first'             => 1,
    628                         'from_id'           => 120841817,
    629                         'to_id'             => null
    630                     )
    631             );
    632            
    633            
    634             $result = $http->request(
    635                 'https://api.twitch.tv/helix/webhooks/hub',
    636                 array(
    637                     'method'     => 'POST',
    638                     'stream'     => false,
    639                     'filename'   => false,
    640                     'decompress' => false,
    641                     'headers' => array(
    642                         'Accept'            => 'application/json',
    643                         'Content-Type'      => 'application/json; charset=utf-8',
    644                         'Client-ID'         => twitchpress_get_app_id(),
    645                     ),
    646                     'body' => $body
    647                 )
    648             );
    649         }
    650         */       
     518        ob_end_flush();               
    651519    }
    652520}
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-menus.php

    r2472434 r2527323  
    3737    function secondary_menu_items() {
    3838       
    39         add_submenu_page( $this->slug, __('Channels', $this->slug), __('Channels', $this->slug), 'manage_options', 'edit.php?post_type=channels', '' );
     39        add_submenu_page( $this->slug, __('Channels',      $this->slug), __('Channels', $this->slug), 'manage_options', 'edit.php?post_type=channels', '' );
    4040       
    4141        if( 'yes' == get_option( 'twitchpress_perks_switch' ) ) {
    42             add_submenu_page( $this->slug, __('Perks',    $this->slug), __('Perks',    $this->slug), 'manage_options', 'edit.php?post_type=perks', '' );
     42            add_submenu_page( $this->slug, __('Perks',     $this->slug), __('Perks',    $this->slug), 'manage_options', 'edit.php?post_type=perks', '' );
    4343        }
    4444       
    4545        if( 'yes' == get_option( 'twitchpress_giveaways_switch' ) ) {
    46             add_submenu_page( $this->slug, __('Giveaways',$this->slug), __('Giveaways',$this->slug), 'manage_options', 'edit.php?post_type=giveaways', '' );
     46            add_submenu_page( $this->slug, __('Giveaways', $this->slug), __('Giveaways', $this->slug), 'manage_options', 'edit.php?post_type=giveaways', '' );
    4747        }
    4848       
    49         if( 'yes' == get_option( 'twitchpress_webhooks_switch' ) ) {
    50             add_submenu_page( $this->slug, __('Webhooks',    $this->slug), __('Webhooks',    $this->slug), 'manage_options', 'edit.php?post_type=webhooks', '' );       
     49        if( 'yes' == get_option( 'twitchpress_webhooks_switch' )  ) {     
     50            add_submenu_page( $this->slug, __('Webhooks',  $this->slug), __('Webhooks', $this->slug), 'manage_options', 'edit.php?post_type=webhooks', '' );       
     51        }
     52                 
     53        if( 'yes' == get_option( 'twitchpress_bot_switch' ) ) {
     54            add_submenu_page( $this->slug, __('Bot',       $this->slug), __('Bot',      $this->slug), 'manage_options', 'twitchpress_bot', array( $this, 'bot_page' ) );
    5155        }
    5256       
    53         if( 'yes' == get_option( 'twitchpress_bot_switch' ) ) {
    54             add_submenu_page( $this->slug, __('Bot',         $this->slug), __('Bot',         $this->slug), 'manage_options', 'twitchpress_bot', array( $this, 'bot_page' ) );
    55         }
    56        
    57         add_submenu_page( $this->slug, __('Tools',    $this->slug), __('Tools',    $this->slug), 'manage_options', 'twitchpress_tools', array( $this, 'tools_page' ) );
    58         add_submenu_page( $this->slug, __('Data',     $this->slug), __('Data',     $this->slug), 'manage_options', 'twitchpress_data', array( $this, 'data_page' ) );
     57        add_submenu_page( $this->slug, __('Tools', $this->slug), __('Tools', $this->slug), 'manage_options', 'twitchpress_tools', array( $this, 'tools_page' ) );
     58        add_submenu_page( $this->slug, __('Data',  $this->slug), __('Data',  $this->slug), 'manage_options', 'twitchpress_data', array( $this, 'data_page' ) );
    5959    }
    6060   
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-notices.php

    r2185787 r2527323  
    431431
    432432endif;
    433 
    434 TwitchPress_Admin_Notices::init();
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-quicktools.php

    r2488173 r2527323  
    534534
    535535    /**
    536     * Install/update the current pro-extension.
    537     *
    538     * @version 1.0
    539     */
    540     public function tool_install_pro() {
    541         /**
    542         * Description of values.
    543         *
    544         * title       - give the tool a name.
    545         * description - describe what the tool does.
    546         * version     - tools must be versioned to give users warning
    547         * author      - we have to know who to come to for help with a tool
    548         * url         - link to a tutorial or other documentation
    549         * category    - a way to group tools
    550         * capability  - apply security using a core or custom capability
    551         * option      - add option name if configuration required to use tool
    552         */
    553         $tool_info = array(
    554             'title'       => __( 'Install Pro Edition', 'multitool' ),
    555             'description' => __( 'Run installation of Pro extension (use for updating also).', 'multitool' ),
    556             'version'     => '1.1',
    557             'author'      => 'Ryan Bayne',
    558             'url'         => '',
    559             'category'    => 'extensions',
    560             'capability'  => 'activate_plugins',
    561             'option'      => null,
    562             'function'    => __FUNCTION__,
    563             'plugin'      => 'TwitchPress',
    564         );
    565        
    566         if( $this->return_tool_info ){ return $tool_info; }     
    567        
    568         if( !current_user_can( $tool_info['capability'] ) ) { return; }
    569 
    570         $notices = new TwitchPress_Admin_Notices();
    571        
    572         // Prepare Streamlabs Applications object...
    573         $example = new TwitchPress_EXAMPLE_API();
    574 
    575         // Check if Streamlabs Application is ready...
    576         if( !$example->streamlabs_app_ready ) {
    577             $notices->error( __( 'EXAMPLE Application Not Ready', 'twitchpress' ), __( 'A message here.', 'twitchpress' ) );
    578             return;   
    579         }
    580                
    581         /*
    582             Your tools unique code goes here. Make it do something!
    583         */
    584     }
    585    
    586     /**
    587536    * Discord Test Tool
    588537    *
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-settings.php

    r2477212 r2527323  
    100100
    101101    /**
    102      * Add a message.
     102     * Add a message for display under the tabs on settings pages...
    103103     * @param string $text
    104104     */
     
    108108
    109109    /**
    110      * Add an error.
     110     * Add an error for display under the tabs on settings pages...
    111111     * @param string $text
    112112     */
     
    467467                case 'checkbox' :
    468468               
    469                     $option_value    = self::get_option( $value['id'], $value['default'] );
     469                    $option_value = self::get_option( $value['id'], $value['default'] );
    470470                   
    471471                    $visbility_class = array();
     
    711711                            if( !ctype_alnum( $value ) ) {         
    712712                                //add_settings_error( string $setting, string $code, string $message, string $type = 'error' )
    713                                 self::add_error( sprintf( __( "A form needs your attention. The %s field must be alphabetical and numerical characters only.", "twitchpress" ), $option['title']) );   
     713                                self::add_error( sprintf( __( "An entry needs your attention. The %s field must be alphabetical and numerical characters only.", "twitchpress" ), $option['title']) );   
    714714                                // Unset the option to prevent it being saved...
    715715                                unset( $update_options[ $option['id'] ] );                           
  • twitchpress/trunk/includes/admin/class.twitchpress-admin-setup-wizard.php

    r2488173 r2527323  
    968968                <li><?php echo $wpdb->prefix; ?>_twitchpress_activity</li>
    969969                <li><?php echo $wpdb->prefix; ?>_twitchpress_errors</li>
    970                 <li><?php echo $wpdb->prefix; ?>_twitchpress_outcomes</li>
    971970                <li><?php echo $wpdb->prefix; ?>_twitchpress_endpoints</li>
    972971                <li><?php echo $wpdb->prefix; ?>_twitchpress_meta</li>
  • twitchpress/trunk/includes/admin/class.twitchpress-admin.php

    r2472434 r2527323  
    5959        // Class
    6060        include_once( dirname( __FILE__ ) . '/class.twitchpress-admin-menus.php' );
    61         include_once( dirname( __FILE__ ) . '/class.twitchpress-admin-notices.php' );
    6261        include_once( dirname( __FILE__ ) . '/class.twitchpress-admin-assets.php' );
    6362        include_once( dirname( __FILE__ ) . '/class.twitchpress-admin-help.php' );
  • twitchpress/trunk/includes/admin/settings/class.twitchpress-settings-bugnet.php

    r2210753 r2527323  
    104104            $result = $install->install();
    105105           
    106             TwitchPress_Admin_Settings::add_message( __( 'BugNet has been installed', 'twitchpress' ) );               
     106            TwitchPress_Admin_Settings::add_message( __( 'BugNet has been installed.', 'twitchpress' ) );               
    107107        }
    108108        else
     
    201201                array(
    202202                    'title'    => __( 'Single User Error Dump', 'twitchpress-login' ),
    203                     'desc'     => __( 'Enter a WP user ID to limit error dumping to that user.', 'twitchpress-login' ),
     203                    'desc'     => __( 'Enter a WP user ID to restrict error output to that user only.', 'twitchpress-login' ),
    204204                    'id'       => 'bugnet_error_dump_user_id',
    205205                    'css'      => 'width:75px;',
     
    472472            $bugnet_version = BUGNET_VERSION;
    473473           
    474             $settings = apply_filters( 'twitchpress_bugnet_version_settings', array(
     474            $settings = apply_filters( 'twitchpress_bugnet_installation_settings', array(
    475475           
    476476                array(
     
    482482               
    483483                array(
    484                     'desc'            => __( 'name: the Twitch username can change.', 'twitchpress' ),
    485484                    'id'              => 'bugnet_version',
    486485                    'default'         => BUGNET_VERSION,
     
    489488               
    490489                array(
    491                     'desc'            => __( 'name: the Twitch username can change.', 'twitchpress' ),
    492490                    'id'              => 'bugnet_first_installation_request',
    493491                    'default'         => BUGNET_VERSION,
  • twitchpress/trunk/includes/admin/settings/class.twitchpress-settings-general.php

    r2496316 r2527323  
    4848            'removal'   => __( 'Plugin Removal', 'twitchpress' ),
    4949            'advanced'  => __( 'Advanced', 'twitchpress' ),
    50             'systems'   => __( 'Systems', 'twitchpress' ),
     50            'systems'   => __( 'System Switches', 'twitchpress' ),
    5151            //'livemenu'  => __( 'Live Menu', 'twitchpress' ),
    52             //'team'      => __( 'Main Team', 'twitchpress' ),
     52            'team'      => __( 'Main Team', 'twitchpress' ),
    5353        );
    5454       
     
    6868     * Save settings method runs along with save() method in class.twitchpress-admin-settings.php
    6969     *
    70      * @version 1.2
     70     * @version 2.0
    7171     */
    7272    public function save() {     
    7373        global $current_section;
    7474        $settings = $this->get_settings( $current_section );
    75         TwitchPress_Admin_Settings::save_fields( $settings );
     75        TwitchPress_Admin_Settings::save_fields( $settings ); // Use the saved values where possible...
    7676 
    77         // React to team section being submitted, do not use $_POST values though use the saved values...
    78         if( isset( $_POST['twitchpress_team_name'] ) ) {
    79             $twitch = new TwitchPress_Twitch_API();
    80             $team = $twitch->get_team( get_option( 'twitchpress_team_name' ) );
    81             if( $team ) {
    82                 //var_dump( $team->ID );
    83             }       
     77        // React to team section being submitted...
     78        if( !isset( $_POST['twitchpress_team_name'] ) ) {
     79            TwitchPress_Admin_Settings::add_error( sprintf( __( 'Please enter your teams name as shown on Twitch.', 'twitchpress' ), $team_id ) );
     80            return;
    8481        }
     82       
     83        $twitch_api = new TwitchPress_Twitch_API();
     84        $twitch_api->get_team( get_option( 'twitchpress_team_name' ) );
     85                       
     86        if( $twitch_api->curl_object->response_code == 200 ) {
     87            $team_id = $twitch_api->curl_object->curl_reply_body->data['0']->id;
     88            twitchpress_update_main_channels_team_id( $team_id );   
     89            TwitchPress_Admin_Settings::add_message( sprintf( __( 'Your main teams ID is %d and will be used to request team data from Twitch.', 'twitchpress' ), $team_id ) );
     90        } elseif( $twitch_api->curl_object->response_code == 404 ) {
     91            TwitchPress_Admin_Settings::add_error( sprintf( __( 'Your team could not be found. Ensure the name is entered correctly and try again.', 'twitchpress' ), $team_id ) );
     92        }       
    8593    } 
    8694
     
    102110                    'title' => __( 'General Settings', 'twitchpress' ),
    103111                    'type'     => 'title',
    104                     'desc'     => __( 'You can support development by opting into the improvement program. It does not send sensitive data. The plugin can also request feedback occasionally, this is rare to avoid harassing you or users. Data collected is send to Ryan Bayne.', 'twitchpress' ),
     112                    'desc'     => __( 'You can support development by opting into the improvement program. It does not send sensitive data. The plugin can also request feedback occasionally, this is rare to avoid harassing you or users. Data collected is sent to Ryan Bayne (Plugin Owner).', 'twitchpress' ),
    105113                    'id'     => 'generalsettings'
    106114                ),
     
    258266                    'title' => __( 'System Switches', 'twitchpress' ),
    259267                    'type'     => 'title',
    260                     'desc'     => __( 'You can enable/disable multiple systems at once here (with care). Please visit system specific Settings views that become available on activation and run first-time installation.', 'twitchpress' ),
     268                    'desc'     => __( 'Use these settings to quickly enable/disable systems.', 'twitchpress' ),
    261269                    'id'     => 'systemsettings',
    262270                ),
     
    273281                         
    274282                array(
    275                     'desc'            => __( 'Giveaways and Raffle System', 'twitchpress' ),
     283                    'desc'            => __( 'Giveaways System (Alpha - test only)', 'twitchpress' ),
    276284                    'id'              => 'twitchpress_giveaways_switch',
    277285                    'default'         => 'no',
     
    283291                           
    284292                array(
    285                     'desc'            => __( 'Perks System', 'twitchpress' ),
     293                    'desc'            => __( 'Perks System (Alpha - test only)', 'twitchpress' ),
    286294                    'id'              => 'twitchpress_perks_switch',
     295                    'default'         => 'no',
     296                    'type'            => 'checkbox',
     297                    'checkboxgroup'   => '',
     298                    'show_if_checked' => 'yes',
     299                    'autoload'        => true,
     300                ), 
     301                                           
     302                array(
     303                    'desc'            => __( 'Webhooks System (Alpha - test only)', 'twitchpress' ),
     304                    'id'              => 'twitchpress_webhooks_switch',
     305                    'default'         => 'no',
     306                    'type'            => 'checkbox',
     307                    'checkboxgroup'   => '',
     308                    'show_if_checked' => 'yes',
     309                    'autoload'        => true,
     310                ), 
     311                               
     312                array(
     313                    'desc'            => __( 'Content Gate System', 'twitchpress' ),
     314                    'id'              => 'twitchpress_gate_switch',
    287315                    'default'         => 'no',
    288316                    'type'            => 'checkbox',
     
    374402                    'title'           => __( 'Twitch Team ID', 'twitchpress' ),
    375403                    'desc'            => __( 'This will be found automatically.', 'twitchpress' ),
    376                     'id'              => 'twitchpress_team_id',
     404                    'id'              => 'twitchpress_main_channel_team_id',
    377405                    'default'         => '',
    378406                    'type'            => 'text',
    379                     'validation'      => 'alphanumeric',
    380407                    'autoload'        => true,
    381408                    'readonly'        => true
  • twitchpress/trunk/includes/admin/settings/class.twitchpress-settings-otherapi.php

    r2334500 r2527323  
    3030        'patron'
    3131    );           
    32    
     32       
    3333    /**
    3434    * Constructor
     
    182182       
    183183           default:
    184                 // Allow extensions to add_action() and run custom procedures for updating app credentials...
     184                // Allow third party plugins to add_action() and run custom procedures for updating app credentials...
    185185                do_action( 'twitchpress_allapi_application_update_' . $service, $service, $url, $key, $secret );
    186186             break;
  • twitchpress/trunk/includes/admin/settings/class.twitchpress-settings-twitch.php

    r2488173 r2527323  
    1818 */
    1919class TwitchPress_Settings_Twitch extends TwitchPress_Settings_Page {
     20   
     21    public $webhooks_ready = null;
    2022
    2123    /**
     
    2325     */
    2426    public function __construct() {
    25 
     27        global $wpdb, $current_section;
     28       
    2629        $this->id    = 'twitch';
    2730        $this->label = __( 'Twitch API', 'twitchpress' );
    28 
     31     
     32        // Establish installation status...
     33        if( twitchpress_webhooks_ready() && $current_section == 'webhooks' ) {
     34            $this->webhooks_ready = false; 
     35            add_filter( 'twitchpress_settings_save_button_text', array( $this, 'custom_save_button_webhooks' ), 1 );         
     36        } else {
     37            $this->webhooks_ready = true;
     38        }
     39       
    2940        add_filter( 'twitchpress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
    3041        add_action( 'twitchpress_settings_' . $this->id, array( $this, 'output' ) );
    3142        add_action( 'twitchpress_settings_save_' . $this->id, array( $this, 'save' ) );
    32         add_action( 'twitchpress_sections_' . $this->id, array( $this, 'output_sections' ) );
     43        add_action( 'twitchpress_sections_' . $this->id, array( $this, 'output_sections' ) ); 
    3344    }
    34 
     45   
     46    /**
     47    * Filter the save button text when on the Webhooks tab and change it according
     48    * to Webhooks installation state...
     49    *
     50    * @param mixed $text original button text i.e. "Save changes"
     51    *
     52    * @version 1.0
     53    */
     54    public function custom_save_button_webhooks( $text ) {
     55        if( !$this->webhooks_ready )
     56        {
     57            return __( 'Install Webhooks System', 'twitchpress' );
     58        }
     59        return $text;
     60    }
     61   
    3562    /**
    3663     * Get sections.
     
    4572            'general'               => __( 'General Options', 'twitchpress' ),
    4673            'syncvalues'            => __( 'Sync Values', 'twitchpress' ),
     74            'webhooks'              => __( 'Webhooks', 'twitchpress' ),
    4775        );
    4876
     
    5482     */
    5583    public function output() {
    56         global $current_section;
    57         $settings = $this->get_settings( $current_section );
     84        global $current_section, $wpdb;
     85       
     86        if( !$this->webhooks_ready && $current_section == 'webhooks' )
     87        {
     88            $settings = $this->get_settings( 'webhooksinstallation' );
     89            $message = __( 'Webhooks System has not been installed yet.', 'twitchpress' );
     90            echo '<div id="message" class="error inline"><p><strong>' . $message . '</strong></p></div>';
     91        }
     92        else
     93        {
     94            $settings = $this->get_settings( $current_section );
     95        }
     96       
    5897        TwitchPress_Admin_Settings::output_fields( $settings );
    5998    }
     
    63102     */
    64103    public function save() {
    65         global $current_section;
    66         $settings = $this->get_settings( $current_section );
     104       
     105        // First time installation by admin is required...
     106        if( isset( $_POST['webhooks_first_installation_request'] ) )
     107        {
     108            $settings = $this->get_settings( 'installation' );
     109           
     110            twitchpress_webhooks_activate_service();
     111           
     112            TwitchPress_Admin_Settings::add_message( __( 'Webhooks system (alpha - test only) has been installed.', 'twitchpress' ) );               
     113        }
     114        else
     115        {       
     116            global $current_section;
     117            $settings = $this->get_settings( $current_section );
     118        }
     119       
    67120        TwitchPress_Admin_Settings::save_fields( $settings );
    68121    }
     
    895948
    896949            ));   
     950        } elseif ( 'webhooksinstallation' == $current_section ) {
     951            $settings = apply_filters( 'twitchpress_webhook_installation_settings', array(
     952           
     953                array(
     954                    'title' => __( 'Webhooks Installation', 'twitchpress' ),
     955                    'type'  => 'title',
     956                    'desc'  => __( 'Webhook system requires an additional database table to be installed.', 'twitchpress' ),
     957                    'id'    => 'webhooksinstallation'
     958                ),
     959               
     960                array(
     961                    'id'              => 'webhooks_first_installation_request',
     962                    'default'         => true,
     963                    'type'            => 'hidden',
     964                ),
     965               
     966                array(
     967                    'id'              => 'twitchpress_webhooks_switch',
     968                    'default'         => 'yes',
     969                    'type'            => 'hidden',
     970                ),
     971                                             
     972                array(
     973                    'type'     => 'sectionend',
     974                    'id'     => 'webhooksinstallation'
     975                )
     976
     977            ));   
     978        } elseif ( 'webhooks' == $current_section ) {
     979            $settings = apply_filters( 'twitchpress_webhook_settings', array(
     980           
     981                array(
     982                    'title' => __( 'Webhooks', 'twitchpress' ),
     983                    'type'  => 'title',
     984                    'desc'  => __( 'Webhooks are a method of allowing Twitch.tv to update your WordPress with changes/events on Twitch.', 'twitch' ),
     985                    'id'    => 'webhookssettings'
     986                ),
     987
     988                array(
     989                    'desc'            => __( 'Webhooks System (Alpha - test only)', 'twitchpress' ),
     990                    'id'              => 'twitchpress_webhooks_switch',
     991                    'default'         => 'no',
     992                    'type'            => 'checkbox',
     993                    'checkboxgroup'   => '',
     994                    'show_if_checked' => 'yes',
     995                    'autoload'        => true,
     996                ),
     997                                                             
     998                array(
     999                    'type'     => 'sectionend',
     1000                    'id'     => 'webhookssettings'
     1001                )
     1002
     1003            ));   
    8971004        }       
    8981005
  • twitchpress/trunk/includes/admin/views/dataviews/class.twitchpress-listtable-apiactivity.php

    r2472434 r2527323  
    4949    * This is not required and was only implemented for demonstration purposes.
    5050    *
    51     * @version 1.2
     51    * @version 1.3
    5252    */
    5353    public function default_items() {
     
    7272            $this->items[$key]['callid']    = $row->callid;
    7373            $this->items[$key]['service']   = $row->service;
    74             $this->items[$key]['api']       = $row->api;
    7574            $this->items[$key]['type']      = $row->type;
    7675            $this->items[$key]['outcome']   = $row->outcome;
    7776            $this->items[$key]['timestamp'] = $row->timestamp;
    78             $this->items[$key]['wpuserid'] = $row->wpuserid;
     77            $this->items[$key]['wpuserid']  = $row->wpuserid;
    7978        }   
    8079       
  • twitchpress/trunk/includes/classes/class.twitchpress-api-logging.php

    r2494470 r2527323  
    115115   
    116116    /**
     117    * Close an entry with a final outcome...
     118    *
    117119    * Stores admin readable context of what took place, sometimes using
    118120    * data returned by Twitch to explain changes.   
     
    124126    * @return WP_Error - this is the only return done
    125127    *
    126     * @version 1.0
     128    * @version 2.0
    127129    */
    128130    static function outcome( $entryid, $outcome, $life = 129600, $meta = array() ) {
     
    135137        }
    136138       
    137         twitchpress_db_insert(
    138             $wpdb->twitchpress_outcomes,
     139        twitchpress_db_insert(              
     140            $wpdb->twitchpress_activity,
    139141            array( 'entryid' => $entryid, 'outcome' => $outcome, 'life' => $life )
    140142        );
  • twitchpress/trunk/includes/classes/class.twitchpress-background-updater.php

    r2472434 r2527323  
    2020 * TwitchPress_Background_Updater Class.
    2121 */
    22 class TwitchPress_Background_Updater extends TwitchPress_Background_Process {
     22class TwitchPress_Background_Updater extends TwitchPress_Background_Processing {
    2323
    2424    /**
  • twitchpress/trunk/includes/classes/class.twitchpress-curl.php

    r2494470 r2527323  
    340340            'headers'    => $this->headers,
    341341            'method'     => strtoupper( $this->type ),
    342             'body'       => $this->curl_request_body,
     342            'body'       => json_encode( $this->curl_request_body ),
    343343            'user-agent' => 'curl/' . $this->curl_version['version'],
    344344            'stream'     => false,
     
    476476    */
    477477    public function call_execute() {   
    478          
     478          
    479479        $this->logging_initiate(); 
    480480       
  • twitchpress/trunk/includes/classes/class.twitchpress-posts-gate.php

    r2488173 r2527323  
    2020    public function init() {
    2121        add_filter( 'the_content', array( __CLASS__, 'gate' ), 20 );
    22         add_action( 'add_meta_boxes', array( __CLASS__, 'add_custom_boxes' ) );
     22        add_action( 'add_meta_boxes_post', array( __CLASS__, 'add_custom_boxes' ) );
     23        add_action( 'add_meta_boxes_page', array( __CLASS__, 'add_custom_boxes' ) );
    2324        add_action( 'save_post', array( __CLASS__, 'save_twitchpress_post_gate_options' ) );       
    2425    } 
  • twitchpress/trunk/includes/classes/class.twitchpress-subscriptions.php

    r2494470 r2527323  
    320320    */
    321321    public function twitch_subscription_status_save( $user_id ) {
    322         $this->sync_user( $user_id, false, true );   
     322        twitchpress_user_sub_sync_single( $user_id, false );   
    323323    }
    324324           
  • twitchpress/trunk/includes/classes/class.twitchpress-tables-installation.php

    r2477212 r2527323  
    1010        'twitchpress_activity',  /* entryid, callid, service, function (__FUNCTION__), type (get,post,put,patch,delete), outcome (granted,rejected,failure), life */
    1111        'twitchpress_errors',    /* errorid, entryid, code (usually HTTP code but string allowed), error (message) */
    12         'twitchpress_outcomes',   /* resultid, entryid, outcome, state (raw,modified,custom), life */
    1312        'twitchpress_endpoints', /* endpointid, api, endpoint, firstuse, lastuse */
    1413        'twitchpress_meta',      /* metaid, entryid, metakey, metavalue */   
     
    110109description longtext,
    111110outcome longtext,
     111life bigint(20) NOT NULL DEFAULT '86400',
    112112PRIMARY KEY (entryid)
    113113) $charset_collate; ";
  • twitchpress/trunk/includes/functions/functions.twitchpress-database.php

    r2472434 r2527323  
    365365 * @global array $wpdb
    366366 * @param string $table_name
     367 *
    367368 * @return boolean, true if table found, else if table does not exist
    368369 */
  • twitchpress/trunk/includes/integration/class.twitchpress-ultimate-member.php

    r2488173 r2527323  
    9090
    9191        if( !is_user_logged_in() ) { return false; }
    92        
    93         if( !twitchpress_is_sync_due( __FILE__, __FUNCTION__, __LINE__, 120 ) ) { return; }
    94                
     92
    9593        // Avoid processing the owner of the main channel (might not be admin with ID 1)
    9694        if( twitchpress_is_current_user_main_channel_owner() ) { return; }
     
    111109    */
    112110    public function set_twitch_subscribers_um_role( $wp_user_id ) {
    113         if( !twitchpress_is_sync_due( __FILE__, __FUNCTION__, __LINE__, 60 ) ) { return; }
    114        
    115111        // Get the current filter to help us trace backwards from log entries.
    116112        $filter = current_filter();
  • twitchpress/trunk/includes/libraries/bugnet/class.bugnet-install-database.php

    r2472434 r2527323  
    111111        $wpdb->twitchpress_activity  = "{$wpdb->prefix}twitchpress_activity";
    112112        $wpdb->twitchpress_errors    = "{$wpdb->prefix}twitchpress_errors";
    113         $wpdb->twitchpress_outcomes  = "{$wpdb->prefix}twitchpress_outcomes";
    114113        $wpdb->twitchpress_endpoints = "{$wpdb->prefix}twitchpress_endpoints";
    115114        $wpdb->twitchpress_meta      = "{$wpdb->prefix}twitchpress_meta";   
  • twitchpress/trunk/includes/libraries/class.async-request.php

    r2474554 r2527323  
    66 * @author A5hleyRich (Original)
    77 *
    8  * @package WP-Background-Processing
    9  *
    108 * @link https://github.com/A5hleyRich/wp-background-processing/
    119 */
     
    8482        public function data( $data ) {
    8583            $this->data = $data;
    86 
    8784            return $this;
    8885        }
    8986
    9087        /**
    91          * Dispatch the async request
     88         * Dispatch the async request...
    9289         *
    9390         * @return array|WP_Error
     
    10198
    10299        /**
    103          * Get query args
     100         * Get query args...
    104101         *
    105102         * @return array
     
    117114                   
    118115        /**
    119          * Get query URL
     116         * Get query URL...
    120117         *
    121118         * @return string
  • twitchpress/trunk/includes/libraries/class.background-process.php

    r2474554 r2527323  
    1414defined( 'ABSPATH' ) || die( 'Direct script access is not allowed!' );
    1515
    16 if ( ! class_exists( 'TwitchPress_Background_Process' ) ) {
     16if ( ! class_exists( 'TwitchPress_Background_Processing' ) ) {
    1717                                                         
    1818    /**
     
    2626     * @link https://github.com/A5hleyRich/wp-background-processing/blob/master/classes/wp-background-process.php
    2727     */
    28     abstract class TwitchPress_Background_Process extends TwitchPress_Async_Request {
     28    abstract class TwitchPress_Background_Processing extends TwitchPress_Async_Request {
    2929
    3030        /**
     
    7878                               
    7979        /**
    80          * Dispatch
     80         * Dispatch by performing a HTTP POST...
    8181         *
    8282         * @access public
     
    8787            $this->schedule_event();
    8888
    89             // Perform remote post.
     89            // Perform remote post
    9090            return parent::dispatch();
    9191        }
     
    100100        public function push_to_queue( $data ) {
    101101            $this->data[] = $data;
    102 
    103102            return $this;
    104103        }
     
    193192                                           
    194193        /**
    195          * Is queue empty
     194         * Is queue empty...
    196195         *
    197196         * @return bool
     197         *
     198         * @version 1.0
    198199         */
    199200        protected function is_queue_empty() {
     
    267268         *
    268269         * @return stdClass Return the first batch from the queue
     270         *
     271         * @version 1.0
    269272         */
    270273        protected function get_batch() {
     
    512515         */
    513516        abstract protected function task( $item );
    514 
    515517    }
    516518}
  • twitchpress/trunk/includes/libraries/twitch/helix/class.twitch-api.php

    r2494470 r2527323  
    327327        $new_curl->final_prep();
    328328        $new_curl->do_call();
    329         $new_curl->call_array['response']['body'] = json_decode( $new_curl->call_array['response']['body'] );
    330 
     329        $new_curl->call_array['response']['body'] = $new_curl->call_array['response']['body'];
     330        //$new_curl->call_array['response']['body'] = json_decode( $new_curl->call_array['response']['body'] );
     331        //$new_curl->call_array['response']['body'] = http_build_query( $new_curl->call_array['response']['body'] );
     332
     333       
     334       
    331335        return $new_curl->call_array['response'];         
    332336    }
     
    341345     * @return object entire TwitchPress_Curl() object for handling any way required.
    342346     *
    343      * @version 2.0
     347     * @version 3.0
    344348     */
    345349    public function request_app_access_token( $requesting_function = null ){
     
    349353        $this->curl_object->originating_line = __LINE__;
    350354        $this->curl_object->type = 'POST';
    351         $this->curl_object->endpoint = 'https://id.twitch.tv/oauth2/token?client_id=' . twitchpress_get_app_id();
     355        //$this->curl_object->endpoint = 'https://id.twitch.tv/oauth2/token?client_id=' . twitchpress_get_app_id();
     356        $this->curl_object->endpoint = 'https://id.twitch.tv/oauth2/token';
    352357     
    353358        // Set none API related parameters i.e. cache and rate controls...
     
    365370        // Use app credentials from my own registry for sensitive data...
    366371        $twitch_app = TwitchPress_Object_Registry::get( 'twitchapp' );
     372       
     373        $this->curl_object->endpoint = add_query_arg( array(
     374            'client_id'        => $twitch_app->app_id,
     375            'client_secret'    => $twitch_app->app_secret,
     376            'redirect_uri'     => $twitch_app->app_redirect,
     377            'grant_type'       => 'client_credentials'       
     378        ), $this->curl_object->endpoint );
     379
     380        /*
    367381        $this->curl_object->set_curl_body( array(
    368382            'client_id'        => $twitch_app->app_id,
     
    371385            'grant_type'       => 'client_credentials'
    372386        ) );
     387        */
     388       
     389        /*
     390        $this->curl_object->body = array(
     391            'client_id'        => $twitch_app->app_id,
     392            'client_secret'    => $twitch_app->app_secret,
     393            'redirect_uri'     => $twitch_app->app_redirect,
     394            'grant_type'       => 'client_credentials'
     395        );
     396        */
     397       
     398        /*
     399        $this->curl_object->headers = array(
     400            'client_id'        => $twitch_app->app_id,
     401            'client_secret'    => $twitch_app->app_secret,
     402            'redirect_uri'     => $twitch_app->app_redirect,
     403            'grant_type'       => 'client_credentials'
     404        );
     405        */
     406       
    373407        unset($twitch_app);
    374408
     
    545579                 
    546580        $result = $this->curl_object->curl_reply;
    547 
     581        if( is_wp_error( $result ) ) { return false; }
     582       
    548583        $token = array();
    549584
     
    13301365        $this->curl_object->scope = 'user:read:email';
    13311366       
    1332         $result = $this->call();         
     1367        return $this->call();         
    13331368    }
    13341369
     
    16691704        return json_decode( $this->curl_object->curl_reply['body'] );       
    16701705    }
     1706   
     1707    /**
     1708    * put your comment there...
     1709    *
     1710    * @param mixed $broadcaster_user_id
     1711    */
     1712    public function eventsub_channel_update( $wp_post_id, $broadcaster_user_id ) {
     1713        $scope = 'none';
     1714        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     1715        $method = 'POST';
     1716        $type = 'channel.update'; 
     1717
     1718        $this->curl( __FILE__, __FUNCTION__, __LINE__, $method, $endpoint );
     1719       
     1720        $this->curl_object->add_headers( array(
     1721            'Client-ID'     => twitchpress_get_app_id(),
     1722            'Authorization' => 'Bearer ' . twitchpress_get_app_token(),
     1723        ) );
     1724       
     1725        $this->curl_object->curl_request_body = array(
     1726            'type'      => $type,
     1727            'version'   => '1',
     1728            'condition' => array(
     1729                'broadcaster_user_id' => twitchpress_get_main_channels_twitchid(),
     1730            ),
     1731            'transport' => array(
     1732                'method'   => 'webhook',
     1733                'callback' => TWITCHPRESS_WEBHOOK_CALLBACK,
     1734                'secret'   => $wp_post_id . '_' . str_replace( '.', '_', $type ) . '_' . twitchpress_random14()
     1735            )
     1736        );
     1737   
     1738        $this->call();
     1739                                   
     1740        return $this->curl_object->curl_reply_body;
     1741       
     1742        # Channel Update Notification Example
     1743        /* {
     1744            "subscription": {
     1745                "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     1746                "type": "channel.update",
     1747                "version": "1",
     1748                "status": "enabled",
     1749                "cost": 0,
     1750                "condition": {
     1751                   "broadcaster_user_id": "1337"
     1752                },
     1753                 "transport": {
     1754                    "method": "webhook",
     1755                    "callback": "https://example.com/webhooks/callback"
     1756                },
     1757                "created_at": "2019-11-16T10:11:12.123Z"
     1758            },
     1759            "event": {
     1760                "broadcaster_user_id": "1337",
     1761                "broadcaster_user_login": "cool_user",
     1762                "broadcaster_user_name": "Cool_User",
     1763                "title": "Best Stream Ever",
     1764                "language": "en",
     1765                "category_id": "21779",
     1766                "category_name": "Fortnite",
     1767                "is_mature": false
     1768            }
     1769        } */                                         
     1770    }
     1771   
     1772    public function eventsub_channel_follow() {
     1773        $call_authentication = 'none';
     1774        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     1775        $method = 'POST';
     1776        $type = 'channel.follow'; 
     1777       
     1778        /*
     1779                    Channel Follow Request Body
     1780                    Name    Type    Required?    Description
     1781                    type    string    yes    The subscription type name: channel.follow.
     1782                    version    string    yes    The subscription type version: 1.
     1783                    condition     condition     yes    Subscription-specific parameters.
     1784                    transport     transport     yes    Transport-specific parameters.
     1785                    Channel Follow Webhook Example
     1786                    {
     1787                        "type": "channel.follow",
     1788                        "version": "1",
     1789                        "condition": {
     1790                            "broadcaster_user_id": "1337"
     1791                        },
     1792                        "transport": {
     1793                            "method": "webhook",
     1794                            "callback": "https://example.com/webhooks/callback",
     1795                            "secret": "s3cRe7"
     1796                        }
     1797                    }
     1798                    Channel Follow Notification Payload
     1799                    Name    Type    Description
     1800                    subscription     subscription     Metadata about the subscription.
     1801                    event     event     The event information. Contains the user ID and user name of the follower and the broadcaster user ID and broadcaster user name.
     1802                    Channel Follow Webhook Notification Example
     1803                    {
     1804                        "subscription": {
     1805                            "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     1806                            "type": "channel.follow",
     1807                            "version": "1",
     1808                            "status": "enabled",
     1809                            "cost": 0,
     1810                            "condition": {
     1811                               "broadcaster_user_id": "1337"
     1812                            },
     1813                             "transport": {
     1814                                "method": "webhook",
     1815                                "callback": "https://example.com/webhooks/callback"
     1816                            },
     1817                            "created_at": "2019-11-16T10:11:12.123Z"
     1818                        },
     1819                        "event": {
     1820                            "user_id": "1234",
     1821                            "user_login": "cool_user",
     1822                            "user_name": "Cool_User",
     1823                            "broadcaster_user_id": "1337",
     1824                            "broadcaster_user_login": "cooler_user",
     1825                            "broadcaster_user_name": "Cooler_User",
     1826                            "followed_at": "2020-07-15T18:16:11.17106713Z"
     1827                        }
     1828                    }  */           
     1829    }
     1830   
     1831    public function eventsub_channel_subscribe() {
     1832        $call_authentication = 'channel:read:subscriptions';
     1833        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     1834        $method = 'POST';
     1835        $type = 'channel.subscribe'; 
     1836       
     1837       
     1838        /*
     1839                            Channel Subscribe Request Body
     1840                    Name    Type    Required?    Description
     1841                    type    string    yes    The subscription type name: channel.subscribe.
     1842                    version    string    yes    The subscription type version: 1.
     1843                    condition     condition     yes    Subscription-specific parameters.
     1844                    transport     transport     yes    Transport-specific parameters.
     1845                    Channel Subscribe Webhook Example
     1846                    {
     1847                        "type": "channel.subscribe",
     1848                        "version": "1",
     1849                        "condition": {
     1850                            "broadcaster_user_id": "1337"
     1851                        },
     1852                        "transport": {
     1853                            "method": "webhook",
     1854                            "callback": "https://example.com/webhooks/callback",
     1855                            "secret": "s3cRe7"
     1856                        }
     1857                    }
     1858                    Channel Subscribe Notification Payload
     1859                    Name    Type    Description
     1860                    subscription     subscription     Metadata about the subscription.
     1861                    event     event     The event information. Contains the user ID and user name of the subscriber, the broadcaster user ID and broadcaster user name, and whether the subscription is a gift.
     1862                    Channel Subscribe Webhook Notification Example
     1863                    {
     1864                        "subscription": {
     1865                            "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     1866                            "type": "channel.subscribe",
     1867                            "version": "1",
     1868                            "status": "enabled",
     1869                            "cost": 0,
     1870                            "condition": {
     1871                               "broadcaster_user_id": "1337"
     1872                            },
     1873                             "transport": {
     1874                                "method": "webhook",
     1875                                "callback": "https://example.com/webhooks/callback"
     1876                            },
     1877                            "created_at": "2019-11-16T10:11:12.123Z"
     1878                        },
     1879                        "event": {
     1880                            "user_id": "1234",
     1881                            "user_login": "cool_user",
     1882                            "user_name": "Cool_User",
     1883                            "broadcaster_user_id": "1337",
     1884                            "broadcaster_user_login": "cooler_user",
     1885                            "broadcaster_user_name": "Cooler_User",
     1886                            "tier": "1000",
     1887                            "is_gift": false
     1888                        }
     1889                    } 
     1890                   
     1891                    */   
     1892    }
     1893   
     1894    public function eventsub_channel_cheer() {
     1895        $call_authentication = 'bits:read';
     1896        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     1897        $method = 'POST';
     1898        $type = 'channel.cheer';   
     1899       
     1900       
     1901       
     1902        /*
     1903                    Channel Cheer Request Body
     1904                    Name    Type    Required?    Description
     1905                    type    string    yes    The subscription type name: channel.cheer.
     1906                    version    string    yes    The subscription type version: 1.
     1907                    condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to receive cheer notifications for.
     1908                    transport     transport     yes    Transport-specific parameters.
     1909                    Channel Cheer Webhook Example
     1910                    {
     1911                        "type": "channel.cheer",
     1912                        "version": "1",
     1913                        "condition": {
     1914                            "broadcaster_user_id": "1337"
     1915                        },
     1916                        "transport": {
     1917                            "method": "webhook",
     1918                            "callback": "https://example.com/webhooks/callback",
     1919                            "secret": "s3cRe7"
     1920                        }
     1921                    }
     1922                    Channel Cheer Notification Payload
     1923                    Name    Type    Description
     1924                    subscription     subscription     Metadata about the subscription.
     1925                    event     event     The event information. Contains the user ID and user name of the cheering user along with the broadcaster user id and broadcaster user name.
     1926                    Channel Cheer Notification Example
     1927                    {
     1928                        "subscription": {
     1929                            "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     1930                            "type": "channel.cheer",
     1931                            "version": "1",
     1932                            "status": "enabled",
     1933                            "cost": 0,
     1934                            "condition": {
     1935                                "broadcaster_user_id": "1337"
     1936                            },
     1937                             "transport": {
     1938                                "method": "webhook",
     1939                                "callback": "https://example.com/webhooks/callback"
     1940                            },
     1941                            "created_at": "2019-11-16T10:11:12.123Z"
     1942                        },
     1943                        "event": {
     1944                            "is_anonymous": false,
     1945                            "user_id": "1234",          // null if is_anonymous=true
     1946                            "user_login": "cool_user",  // null if is_anonymous=true
     1947                            "user_name": "Cool_User",   // null if is_anonymous=true
     1948                            "broadcaster_user_id": "1337",
     1949                            "broadcaster_user_login": "cooler_user",
     1950                            "broadcaster_user_name": "Cooler_User",
     1951                            "message": "pogchamp",
     1952                            "bits": 1000
     1953                        }
     1954                    }
     1955                   
     1956                   
     1957                    */   
     1958    }
     1959   
     1960    public function eventsub_channel_raid() {
     1961        $call_authentication = 'none';
     1962        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     1963        $method = 'POST';
     1964        $type = 'channel.raid';   
     1965       
     1966       
     1967        /*
     1968                    Channel Raid Request Body
     1969                    Name    Type    Required?    Description
     1970                    type    string    yes    The subscription type name: channel.raid.
     1971                    version    string    yes    The subscription type version: 1.
     1972                    condition     condition     yes    Subscription-specific parameters. Pass in either from_broadcaster_user_id or to_broadcaster_user_id. If you pass in both parameters you will receive an error.
     1973                    transport     transport     yes    Transport-specific parameters.
     1974                    Channel Raid Webhook Example
     1975                    {
     1976                        "type": "channel.raid",
     1977                        "version": "1",
     1978                        "condition": {
     1979                            "to_broadcaster_user_id": "1337" // could provide from_broadcaster_user_id instead
     1980                        },
     1981                        "transport": {
     1982                            "method": "webhook",
     1983                            "callback": "https://example.com/webhooks/callback",
     1984                            "secret": "s3cRe7"
     1985                        }
     1986                    }
     1987                    Channel Raid Notification Payload
     1988                    Name    Type    Description
     1989                    subscription     subscription     Metadata about the subscription.
     1990                    event     event     The event information. Contains the from and to broadcaster information along with the number of viewers in the raid. Will only notify for raids that appear in chat.
     1991                    Channel Raid Notification Example
     1992                    {
     1993                        "subscription": {
     1994                            "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     1995                            "type": "channel.raid",
     1996                            "version": "1",
     1997                            "status": "enabled",
     1998                            "cost": 0,
     1999                            "condition": {
     2000                                "to_broadcaster_user_id": "1337"
     2001                            },
     2002                             "transport": {
     2003                                "method": "webhook",
     2004                                "callback": "https://example.com/webhooks/callback"
     2005                            },
     2006                            "created_at": "2019-11-16T10:11:12.123Z"
     2007                        },
     2008                        "event": {
     2009                            "from_broadcaster_user_id": "1234",
     2010                            "from_broadcaster_user_login": "cool_user",
     2011                            "from_broadcaster_user_name": "Cool_User",
     2012                            "to_broadcaster_user_id": "1337",
     2013                            "to_broadcaster_user_login": "cooler_user",
     2014                            "to_broadcaster_user_name": "Cooler_User",
     2015                            "viewers": 9001
     2016                        }
     2017                    }*/     
     2018    }
     2019   
     2020    public function eventsub_channel_ban() {
     2021        $call_authentication = 'channel:moderate';
     2022        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2023        $method = 'POST';
     2024        $type = 'channel.ban';   
     2025                    /*         
     2026                    Channel Ban Request Body
     2027                    Name    Type    Required?    Description
     2028                    type    string    yes    The subscription type name: channel.ban.
     2029                    version    string    yes    The subscription type version: 1.
     2030                    condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to receive ban notifications for.
     2031                    transport     transport     yes    Transport-specific parameters.
     2032                    Channel Ban Webhook Example
     2033                    {
     2034                        "type": "channel.ban",
     2035                        "version": "1",
     2036                        "condition": {
     2037                            "broadcaster_user_id": "1337"
     2038                        },
     2039                        "transport": {
     2040                            "method": "webhook",
     2041                            "callback": "https://example.com/webhooks/callback",
     2042                            "secret": "s3cRe7"
     2043                        }
     2044                    }
     2045                    Channel Ban Notification Payload
     2046                    Name    Type    Description
     2047                    subscription     subscription     Metadata about the subscription.
     2048                    event     event     The event information. Will notify on timeouts as well as bans. Contains the user ID and user name of the banned user, the broadcaster user ID and broadcaster user name, the user ID and user name of the moderator who issued the ban/timeout, the reason, and expiration time if it is a timeout.
     2049                    Channel Ban Notification Example
     2050                    {
     2051                        "subscription": {
     2052                            "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2053                            "type": "channel.ban",
     2054                            "version": "1",
     2055                            "status": "enabled",
     2056                            "cost": 0,
     2057                            "condition": {
     2058                                "broadcaster_user_id": "1337"
     2059                            },
     2060                             "transport": {
     2061                                "method": "webhook",
     2062                                "callback": "https://example.com/webhooks/callback"
     2063                            },
     2064                            "created_at": "2019-11-16T10:11:12.123Z"
     2065                        },
     2066                        "event": {
     2067                            "user_id": "1234",
     2068                            "user_login": "cool_user",
     2069                            "user_name": "Cool_User",
     2070                            "broadcaster_user_id": "1337",
     2071                            "broadcaster_user_login": "cooler_user",
     2072                            "broadcaster_user_name": "Cooler_User",
     2073                            "moderator_user_id": "1339",
     2074                            "moderator_user_login": "mod_user",
     2075                            "moderator_user_name": "Mod_User",
     2076                            "reason": "Offensive language",
     2077                            "ends_at": "2020-07-15T18:16:11.17106713Z",
     2078                            "is_permanent": false
     2079                        }
     2080                    }   */         
     2081    }
     2082   
     2083    public function eventsub_channel_unban() {
     2084        $call_authentication = 'channel:moderate';
     2085        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2086        $method = 'POST';
     2087        $type = 'channel.unban';   
     2088       
     2089                   /*
     2090                    Channel Unban Request Body
     2091                    Name    Type    Required?    Description
     2092                    type    string    yes    The subscription type name: channel.unban.
     2093                    version    string    yes    The subscription type version: 1.
     2094                    condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to receive unban notifications for.
     2095                    transport     transport     yes    Transport-specific parameters.
     2096                    Channel Unban Webhook Example
     2097                    {
     2098                        "type": "channel.unban",
     2099                        "version": "1",
     2100                        "condition": {
     2101                            "broadcaster_user_id": "1337"
     2102                        },
     2103                        "transport": {
     2104                            "method": "webhook",
     2105                            "callback": "https://example.com/webhooks/callback",
     2106                            "secret": "s3cRe7"
     2107                        }
     2108                    }
     2109                    Channel Unban Notification Payload
     2110                    Name    Type    Description
     2111                    subscription     subscription     Metadata about the subscription.
     2112                    event     event     The event information. Contains the user ID and user name of the unbanned user, the broadcaster user id and broadcaster user name, as well as the user ID and user name of the moderator who issued the unban.
     2113                    Channel Unban Notification Example
     2114                    {
     2115                        "subscription": {
     2116                            "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2117                            "type": "channel.unban",
     2118                            "version": "1",
     2119                            "status": "enabled",
     2120                            "cost": 0,
     2121                            "condition": {
     2122                                "broadcaster_user_id": "1337"
     2123                            },
     2124                             "transport": {
     2125                                "method": "webhook",
     2126                                "callback": "https://example.com/webhooks/callback"
     2127                            },
     2128                            "created_at": "2019-11-16T10:11:12.123Z"
     2129                        },
     2130                        "event": {
     2131                            "user_id": "1234",
     2132                            "user_login": "cool_user",
     2133                            "user_name": "Cool_User",
     2134                            "broadcaster_user_id": "1337",
     2135                            "broadcaster_user_login": "cooler_user",
     2136                            "broadcaster_user_name": "Cooler_User",
     2137                             "moderator_user_id": "1339",
     2138                            "moderator_user_login": "mod_user",
     2139                            "moderator_user_name": "Mod_User"
     2140                        }
     2141                    }   */         
     2142    }
     2143   
     2144    public function eventsub_channel_moderator_add() {
     2145        $call_authentication = 'moderation:read';
     2146        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2147        $method = 'POST';
     2148        $type = 'channel.moderator.add';   
     2149       
     2150                    /*
     2151                    Channel Moderator Add Request Body
     2152                    Name    Type    Required?    Description
     2153                    type    string    yes    The subscription type name: channel.moderator.add.
     2154                    version    string    yes    The subscription type version: 1.
     2155                    condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to receive moderator addition notifications for.
     2156                    transport     transport     yes    Transport-specific parameters.
     2157                    Channel Moderator Add Example
     2158                    {
     2159                        "type": "channel.moderator.add",
     2160                        "version": "1",
     2161                        "condition": {
     2162                            "broadcaster_user_id": "1337"
     2163                        },
     2164                        "transport": {
     2165                            "method": "webhook",
     2166                            "callback": "https://example.com/webhooks/callback",
     2167                            "secret": "s3cRe7"
     2168                        }
     2169                    }
     2170                    Channel Moderator Add Notification Payload
     2171                    Name    Type    Description
     2172                    subscription     subscription     Metadata about the subscription.
     2173                    event     event     The event information. Contains user information of the new moderator as well as broadcaster information of the channel the event occurred on.
     2174                    Channel Moderator Add Notification Example
     2175                    {
     2176                        "subscription": {
     2177                            "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2178                            "type": "channel.moderator.add",
     2179                            "version": "1",
     2180                            "status": "enabled",
     2181                            "cost": 0,
     2182                            "condition": {
     2183                                "broadcaster_user_id": "1337"
     2184                            },
     2185                             "transport": {
     2186                                "method": "webhook",
     2187                                "callback": "https://example.com/webhooks/callback"
     2188                            },
     2189                            "created_at": "2019-11-16T10:11:12.123Z"
     2190                        },
     2191                        "event": {
     2192                            "user_id": "1234",
     2193                            "user_login": "mod_user",
     2194                            "user_name": "Mod_User",
     2195                            "broadcaster_user_id": "1337",
     2196                            "broadcaster_user_login": "cooler_user",
     2197                            "broadcaster_user_name": "Cooler_User"
     2198                        }
     2199                    }  */     
     2200             
     2201    }
     2202   
     2203    public function eventsub_channel_moderator_remove() {
     2204        $call_authentication = 'moderation:read';
     2205        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2206        $method = 'POST';
     2207        $type = 'channel.moderator.remove'; 
     2208       
     2209                    /*
     2210                    Channel Moderator Remove Request Body
     2211                    Name    Type    Required?    Description
     2212                    type    string    yes    The subscription type name: channel.moderator.remove.
     2213                    version    string    yes    The subscription type version: 1.
     2214                    condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to receive moderator removal notifications for.
     2215                    transport     transport     yes    Transport-specific parameters.
     2216                    Channel Moderator Remove Example
     2217                    {
     2218                        "type": "channel.moderator.remove",
     2219                        "version": "1",
     2220                        "condition": {
     2221                            "broadcaster_user_id": "1337"
     2222                        },
     2223                        "transport": {
     2224                            "method": "webhook",
     2225                            "callback": "https://example.com/webhooks/callback",
     2226                            "secret": "s3cRe7"
     2227                        }
     2228                    }
     2229                    Channel Moderator Remove Notification Payload
     2230                    Name    Type    Description
     2231                    subscription     subscription     Metadata about the subscription.
     2232                    event     event     The event information. Contains user information of the old moderator as well as broadcaster information of the channel the event occurred on.
     2233                    Channel Moderator Remove Notification Example
     2234                    {
     2235                        "subscription": {
     2236                            "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2237                            "type": "channel.moderator.remove",
     2238                            "version": "1",
     2239                            "status": "enabled",
     2240                            "cost": 0,
     2241                            "condition": {
     2242                                "broadcaster_user_id": "1337"
     2243                            },
     2244                             "transport": {
     2245                                "method": "webhook",
     2246                                "callback": "https://example.com/webhooks/callback"
     2247                            },
     2248                            "created_at": "2019-11-16T10:11:12.123Z"
     2249                        },
     2250                        "event": {
     2251                            "user_id": "1234",
     2252                            "user_login": "not_mod_user",
     2253                            "user_name": "Not_Mod_User",
     2254                            "broadcaster_user_id": "1337",
     2255                            "broadcaster_user_login": "cooler_user",
     2256                            "broadcaster_user_name": "Cooler_User"
     2257                        }
     2258                    }   */           
     2259    }
     2260   
     2261    public function eventsub_channel_points_custom_reward_add() {
     2262        $call_authentication = 'channel:read:redemptions'; // OR channel:manage:redemptions
     2263        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2264        $method = 'POST';
     2265        $type = 'channel.channel_points_custom_reward.add';
     2266       
     2267                    /*
     2268                    Channel Points Custom Reward Add Request Body
     2269                    Name    Type    Required?    Description
     2270                    type    string    yes    The subscription type name: channel.channel_points_custom_reward.add.
     2271                    version    string    yes    The subscription type version: 1.
     2272                    condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to receive channel points customer reward add notifications for.
     2273                    transport     transport     yes    Transport-specific parameters.
     2274                    Channel Points Custom Reward Add Webhook Example
     2275                    {
     2276                        "type": "channel.channel_points_custom_reward.add",
     2277                        "version": "1",
     2278                        "condition": {
     2279                            "broadcaster_user_id": "1337"
     2280                        },
     2281                        "transport": {
     2282                            "method": "webhook",
     2283                            "callback": "https://example.com/webhooks/callback",
     2284                            "secret": "s3cRe7"
     2285                        }
     2286                    }
     2287                    Channel Points Custom Reward Add Notification Payload
     2288                    Name    Type    Description
     2289                    subscription     subscription     Metadata about the subscription.
     2290                    event     event     The event information. Contains data about the custom reward added to the broadcaster’s channel.
     2291                    Channel Points Custom Reward Add Notification Example
     2292                    {
     2293                        "subscription": {
     2294                            "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2295                            "type": "channel.channel_points_custom_reward.add",
     2296                            "version": "1",
     2297                            "status": "enabled",
     2298                            "cost": 0,
     2299                            "condition": {
     2300                                "broadcaster_user_id": "1337"
     2301                            },
     2302                             "transport": {
     2303                                "method": "webhook",
     2304                                "callback": "https://example.com/webhooks/callback"
     2305                            },
     2306                            "created_at": "2019-11-16T10:11:12.123Z"
     2307                        },
     2308                        "event": {
     2309                            "id": "9001",
     2310                            "broadcaster_user_id": "1337",
     2311                            "broadcaster_user_login": "cool_user",
     2312                            "broadcaster_user_name": "Cool_User",
     2313                            "is_enabled": true,
     2314                            "is_paused": false,
     2315                            "is_in_stock": true,
     2316                            "title": "Cool Reward",
     2317                            "cost": 100,
     2318                            "prompt": "reward prompt",
     2319                            "is_user_input_required": true,
     2320                            "should_redemptions_skip_request_queue": false,
     2321                            "cooldown_expires_at": null,
     2322                            "redemptions_redeemed_current_stream": null,
     2323                            "max_per_stream": {
     2324                                "is_enabled": true,
     2325                                "value": 1000
     2326                            },
     2327                            "max_per_user_per_stream": {
     2328                                "is_enabled": true,
     2329                                "value": 1000
     2330                            },
     2331                            "global_cooldown": {
     2332                                "is_enabled": true,
     2333                                "seconds": 1000
     2334                            },
     2335                            "background_color": "#FA1ED2",
     2336                            "image": {
     2337                                "url_1x": "https://static-cdn.jtvnw.net/image-1.png",
     2338                                "url_2x": "https://static-cdn.jtvnw.net/image-2.png",
     2339                                "url_4x": "https://static-cdn.jtvnw.net/image-4.png"
     2340                            },
     2341                            "default_image": {
     2342                                "url_1x": "https://static-cdn.jtvnw.net/default-1.png",
     2343                                "url_2x": "https://static-cdn.jtvnw.net/default-2.png",
     2344                                "url_4x": "https://static-cdn.jtvnw.net/default-4.png"
     2345                            }
     2346                        }
     2347                    }   */           
     2348    }
     2349   
     2350    public function eventsub_channel_points_custom_reward_update() {
     2351        $call_authentication = 'channel:read:redemptions'; // OR channel:manage:redemptions
     2352        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2353        $method = 'POST';
     2354        $type = 'channel.channel_points_custom_reward.update';   
     2355       
     2356       
     2357                /*
     2358                Channel Points Custom Reward Update Request Body
     2359                Name    Type    Required?    Description
     2360                type    string    yes    The subscription type name: channel.channel_points_custom_reward.update.
     2361                version    string    yes    The subscription type version: 1.
     2362                condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to receive channel points custom reward update notifications for. You can optionally pass in a reward id to only receive notifications for a specific reward.
     2363                transport     transport     yes    Transport-specific parameters.
     2364                Channel Points Custom Reward Update Webhook Example
     2365                {
     2366                    "type": "channel.channel_points_custom_reward.update",
     2367                    "version": "1",
     2368                    "condition": {
     2369                        "broadcaster_user_id": "1337",
     2370                        "reward_id": "9001" // optional to only get notifications for a specific reward
     2371                    },
     2372                    "transport": {
     2373                        "method": "webhook",
     2374                        "callback": "https://example.com/webhooks/callback",
     2375                        "secret": "s3cRe7"
     2376                    }
     2377                }
     2378                Channel Points Custom Reward Update Notification Payload
     2379                Name    Type    Description
     2380                subscription     subscription     Metadata about the subscription.
     2381                event     event     The event information. Contains data about the custom reward updated on the broadcaster’s channel.
     2382                Channel Points Custom Reward Update Notification Example
     2383                {
     2384                    "subscription": {
     2385                        "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2386                        "type": "channel.channel_points_custom_reward.update",
     2387                        "version": "1",
     2388                        "status": "enabled",
     2389                        "cost": 0,
     2390                        "condition": {
     2391                            "broadcaster_user_id": "1337"
     2392
     2393                        },
     2394                         "transport": {
     2395                            "method": "webhook",
     2396                            "callback": "https://example.com/webhooks/callback"
     2397                        },
     2398                        "created_at": "2019-11-16T10:11:12.123Z"
     2399                    },
     2400                    "event": {
     2401                        "id": "9001",
     2402                        "broadcaster_user_id": "1337",
     2403                        "broadcaster_user_login": "cool_user",
     2404                        "broadcaster_user_name": "Cool_User",
     2405                        "is_enabled": true,
     2406                        "is_paused": false,
     2407                        "is_in_stock": true,
     2408                        "title": "Cool Reward",
     2409                        "cost": 100,
     2410                        "prompt": "reward prompt",
     2411                        "is_user_input_required": true,
     2412                        "should_redemptions_skip_request_queue": false,
     2413                        "cooldown_expires_at": "2019-11-16T10:11:12.123Z",
     2414                        "redemptions_redeemed_current_stream": 123,
     2415                        "max_per_stream": {
     2416                            "is_enabled": true,
     2417                            "value": 1000
     2418                        },
     2419                        "max_per_user_per_stream": {
     2420                            "is_enabled": true,
     2421                            "value": 1000
     2422                        },
     2423                        "global_cooldown": {
     2424                            "is_enabled": true,
     2425                            "seconds": 1000
     2426                        },
     2427                        "background_color": "#FA1ED2",
     2428                        "image": {
     2429                            "url_1x": "https://static-cdn.jtvnw.net/image-1.png",
     2430                            "url_2x": "https://static-cdn.jtvnw.net/image-2.png",
     2431                            "url_4x": "https://static-cdn.jtvnw.net/image-4.png"
     2432                        },
     2433                        "default_image": {
     2434                            "url_1x": "https://static-cdn.jtvnw.net/default-1.png",
     2435                            "url_2x": "https://static-cdn.jtvnw.net/default-2.png",
     2436                            "url_4x": "https://static-cdn.jtvnw.net/default-4.png"
     2437                        }
     2438                    }
     2439                }     */
     2440           
     2441    }
     2442       
     2443    public function eventsub_channel_points_custom_reward_remove() {
     2444        $call_authentication = 'channel:read:redemptions'; // OR channel:manage:redemptions
     2445        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2446        $method = 'POST';
     2447        $type = 'channel.channel_points_custom_reward.remove';
     2448       
     2449                   /*
     2450                    Channel Points Custom Reward Remove Request Body
     2451                    Name    Type    Required?    Description
     2452                    type    string    yes    The subscription type name: channel.channel_points_custom_reward.remove.
     2453                    version    string    yes    The subscription type version: 1.
     2454                    condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to receive channel points custom reward remove notifications for. You can optionally pass in a reward ID to only receive notifications for a specific reward.
     2455                    transport     transport     yes    Transport-specific parameters.
     2456                    Channel Points Custom Reward Remove Webhook Example
     2457                    {
     2458                        "type": "channel.channel_points_custom_reward.remove",
     2459                        "version": "1",
     2460                        "condition": {
     2461                            "broadcaster_user_id": "1337",
     2462                            "reward_id": "9001" // optional to only get notifications for a specific reward
     2463                        },
     2464                        "transport": {
     2465                            "method": "webhook",
     2466                            "callback": "https://example.com/webhooks/callback",
     2467                            "secret": "s3cRe7"
     2468                        }
     2469                    }
     2470                    Channel Points Custom Reward Remove Notification Payload
     2471                    Name    Type    Description
     2472                    subscription     subscription     Subscription information.
     2473                    event     event     The event information. Contains data about the custom reward removed from the broadcaster’s channel.
     2474                    Channel Points Custom Reward Remove Notification Example
     2475                    {
     2476                        "subscription": {
     2477                            "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2478                            "type": "channel.channel_points_custom_reward.remove",
     2479                            "version": "1",
     2480                            "status": "enabled",
     2481                            "cost": 0,
     2482                            "condition": {
     2483                                "broadcaster_user_id": "1337",
     2484                                "reward_id": 12345
     2485                            },
     2486                             "transport": {
     2487                                "method": "webhook",
     2488                                "callback": "https://example.com/webhooks/callback"
     2489                            },
     2490                            "created_at": "2019-11-16T10:11:12.123Z"
     2491                        },
     2492                        "event": {
     2493                            "id": "9001",
     2494                            "broadcaster_user_id": "1337",
     2495                            "broadcaster_user_login": "cool_user",
     2496                            "broadcaster_user_name": "Cool_User",
     2497                            "is_enabled": true,
     2498                            "is_paused": false,
     2499                            "is_in_stock": true,
     2500                            "title": "Cool Reward",
     2501                            "cost": 100,
     2502                            "prompt": "reward prompt",
     2503                            "is_user_input_required": true,
     2504                            "should_redemptions_skip_request_queue": false,
     2505                            "cooldown_expires_at": "2019-11-16T10:11:12.123Z",
     2506                            "redemptions_redeemed_current_stream": 123,
     2507                            "max_per_stream": {
     2508                                "is_enabled": true,
     2509                                "value": 1000
     2510                            },
     2511                            "max_per_user_per_stream": {
     2512                                "is_enabled": true,
     2513                                "value": 1000
     2514                            },
     2515                            "global_cooldown": {
     2516                                "is_enabled": true,
     2517                                "seconds": 1000
     2518                            },
     2519                            "background_color": "#FA1ED2",
     2520                            "image": {
     2521                                "url_1x": "https://static-cdn.jtvnw.net/image-1.png",
     2522                                "url_2x": "https://static-cdn.jtvnw.net/image-2.png",
     2523                                "url_4x": "https://static-cdn.jtvnw.net/image-4.png"
     2524                            },
     2525                            "default_image": {
     2526                                "url_1x": "https://static-cdn.jtvnw.net/default-1.png",
     2527                                "url_2x": "https://static-cdn.jtvnw.net/default-2.png",
     2528                                "url_4x": "https://static-cdn.jtvnw.net/default-4.png"
     2529                            }
     2530                        }
     2531                    }   */     
     2532       
     2533               
     2534    }
     2535   
     2536    public function eventsub_channel_points_custom_reward_redemption_add() {
     2537        $call_authentication = 'channel:read:redemptions'; // OR channel:manage:redemptions
     2538        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2539        $method = 'POST';
     2540        $type = 'channel.channel_points_custom_reward_redemption.add';       
     2541       
     2542                 /*       
     2543                Channel Points Custom Reward Redemption Add Request Body
     2544                Name    Type    Required?    Description
     2545                type    string    yes    The subscription type name: channel.channel_points_custom_reward_redemption.add.
     2546                version    string    yes    The subscription type version: 1.
     2547                condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to receive channel points custom reward redemption notifications for. You can optionally pass in a reward id to only receive notifications for a specific reward.
     2548                transport     transport     yes    Transport-specific parameters.
     2549                Channel Points Custom Reward Redemption Add Webhook Example
     2550                {
     2551                    "type": "channel.channel_points_custom_reward_redemption.add",
     2552                    "version": "1",
     2553                    "condition": {
     2554                        "broadcaster_user_id": "1337",
     2555                        "reward_id": "9001" // optional to only get notifications for a specific reward
     2556                    },
     2557                    "transport": {
     2558                        "method": "webhook",
     2559                        "callback": "https://example.com/webhooks/callback",
     2560                        "secret": "s3cRe7"
     2561                    }
     2562                }
     2563                Channel Points Custom Reward Redemption Add Notification Payload
     2564                Name    Type    Description
     2565                subscription     subscription     Subscription information.
     2566                event     event     The event information. Contains data about the redemption of the custom reward on the broadcaster’s channel.
     2567                Channel Points Custom Reward Redemption Add Notification Example
     2568                {
     2569                    "subscription": {
     2570                        "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2571                        "type": "channel.channel_points_custom_reward_redemption.add",
     2572                        "version": "1",
     2573                        "status": "enabled",
     2574                        "cost": 0,
     2575                        "condition": {
     2576                            "broadcaster_user_id": "1337"
     2577                        },
     2578                         "transport": {
     2579                            "method": "webhook",
     2580                            "callback": "https://example.com/webhooks/callback"
     2581                        },
     2582                        "created_at": "2019-11-16T10:11:12.123Z"
     2583                    },
     2584                    "event": {
     2585                        "id": "1234",
     2586                        "broadcaster_user_id": "1337",
     2587                        "broadcaster_user_login": "cool_user",
     2588                        "broadcaster_user_name": "Cool_User",
     2589                        "user_id": "9001",
     2590                        "user_login": "cooler_user",
     2591                        "user_name": "Cooler_User",
     2592                        "user_input": "pogchamp",
     2593                        "status": "unfulfilled",
     2594                        "reward": {
     2595                            "id": "9001",
     2596                            "title": "title",
     2597                            "cost": 100,
     2598                            "prompt": "reward prompt"
     2599                        },
     2600                        "redeemed_at": "2020-07-15T17:16:03.17106713Z"
     2601                    }
     2602                }   */     
     2603       
     2604    }
     2605   
     2606    public function eventsub_channel_points_custom_reward_redemption_update() {
     2607        $call_authentication = 'channel:read:redemptions'; // OR channel:manage:redemptions
     2608        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2609        $method = 'POST';
     2610        $type = 'channel.channel_points_custom_reward_redemption.update';   
     2611                   /*
     2612                           
     2613                    Channel Points Custom Reward Redemption Update Request Body
     2614                    Name    Type    Required?    Description
     2615                    type    string    yes    The subscription type name: channel.channel_points_custom_reward_redemption.update.
     2616                    version    string    yes    The subscription type version: 1.
     2617                    condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to receive channel points custom reward redemption update notifications for. You can optionally pass in a reward id to only receive notifications for a specific reward.
     2618                    transport     transport     yes    Transport-specific parameters.
     2619                    Channel Points Custom Reward Redemption Update Webhook Example
     2620                    {
     2621                        "type": "channel.channel_points_custom_reward_redemption.update",
     2622                        "version": "1",
     2623                        "condition": {
     2624                            "broadcaster_user_id": "1337",
     2625                            "reward_id": "9001" // optional to only get notifications for a specific reward
     2626                        },
     2627                        "transport": {
     2628                            "method": "webhook",
     2629                            "callback": "https://example.com/webhooks/callback",
     2630                            "secret": "s3cRe7"
     2631                        }
     2632                    }
     2633                    Channel Points Custom Reward Redemption Update Notification Payload
     2634                    Name    Type    Description
     2635                    subscription     subscription     Subscription information.
     2636                    event     event     The event information. Contains data about the custom reward redemption update from the broadcaster’s channel.
     2637                    Channel Points Custom Reward Redemption Update Notification Example
     2638                    {
     2639                        "subscription": {
     2640                            "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2641                            "type": "channel.channel_points_custom_reward_redemption.update",
     2642                            "version": "1",
     2643                            "status": "enabled",
     2644                            "cost": 0,
     2645                            "condition": {
     2646                                "broadcaster_user_id": "1337"
     2647                            },
     2648                             "transport": {
     2649                                "method": "webhook",
     2650                                "callback": "https://example.com/webhooks/callback"
     2651                            },
     2652                            "created_at": "2019-11-16T10:11:12.123Z"
     2653                        },
     2654                        "event": {
     2655                            "id": "1234",
     2656                            "broadcaster_user_id": "1337",
     2657                            "broadcaster_user_login": "cool_user",
     2658                            "broadcaster_user_name": "Cool_User",
     2659                            "user_id": "9001",
     2660                            "user_login": "cooler_user",
     2661                            "user_name": "Cooler_User",
     2662                            "user_input": "pogchamp",
     2663                            "status": "fulfilled",  // Either fulfilled or cancelled
     2664                            "reward": {
     2665                                "id": "9001",
     2666                                "title": "title",
     2667                                "cost": 100,
     2668                                "prompt": "reward prompt"
     2669                            },
     2670                            "redeemed_at": "2020-07-15T17:16:03.17106713Z"
     2671                        }
     2672                    }     */   
     2673           
     2674    }
     2675   
     2676    public function eventsub_hype_train_begin() {
     2677        $call_authentication = 'channel:read:hype_train';
     2678        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2679        $method = 'POST';
     2680        $type = 'channel.hype_train.begin';     
     2681       
     2682                 /*
     2683                Channel Hype Train Begin Request Body
     2684                Name    Type    Required?    Description
     2685                type    string    yes    The subscription type name: channel.hype_train.begin.
     2686                version    string    yes    The subscription type version: 1.
     2687                condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to hype train begin notifications for.
     2688                transport     transport     yes    Transport-specific parameters.
     2689                Channel Hype Train Begin Webhook Example
     2690                {
     2691                    "type": "channel.hype_train.begin",
     2692                    "version": "1",
     2693                    "condition": {
     2694                        "broadcaster_user_id": "1337"
     2695                    },
     2696                    "transport": {
     2697                        "method": "webhook",
     2698                        "callback": "https://example.com/webhooks/callback",
     2699                        "secret": "s3cRe7"
     2700                    }
     2701                }
     2702                Channel Hype Train Begin Notification Payload
     2703                Name    Type    Description
     2704                subscription     subscription     Subscription information.
     2705                event     event     Event information. Contains hype train information like the level, goal, top contributors, start time, and expiration time.
     2706                Channel Hype Train Notification Example
     2707                {
     2708                    "subscription": {
     2709                        "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2710                        "type": "channel.hype_train.begin",
     2711                        "version": "1",
     2712                        "status": "enabled",
     2713                        "cost": 0,
     2714                        "condition": {
     2715                            "broadcaster_user_id": "1337"
     2716                        },
     2717                         "transport": {
     2718                            "method": "webhook",
     2719                            "callback": "https://example.com/webhooks/callback"
     2720                        },
     2721                        "created_at": "2019-11-16T10:11:12.123Z"
     2722                    },
     2723                    "event": {
     2724                        "broadcaster_user_id": "1337",
     2725                        "broadcaster_user_login": "cool_user",
     2726                        "broadcaster_user_name": "Cool_User",
     2727                        "total": 137,
     2728                        "progress": 137,
     2729                        "goal": 500,
     2730                        "top_contributions": [
     2731                            { "user_id": "123", "user_login": "pogchamp", "user_name": "PogChamp", "type": "bits", "total": 50 },
     2732                            { "user_id": "456", "user_login": "kappa", "user_name": "Kappa", "type": "subscription", "total": 45 }
     2733                        ],
     2734                        "last_contribution": { "user_id": "123", "user_login": "pogchamp", "user_name": "PogChamp", "type": "bits", "total": 50 },
     2735                        "started_at": "2020-07-15T17:16:03.17106713Z",
     2736                        "expires_at": "2020-07-15T17:16:11.17106713Z"
     2737                    }
     2738                }   */       
     2739    }
     2740   
     2741    public function eventsub_hype_train_progress() {
     2742        $call_authentication = 'channel:read:hype_train';
     2743        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2744        $method = 'POST';
     2745        $type = 'channel.hype_train.progress';     
     2746       
     2747                     /*           
     2748                        Channel Hype Train Progress Request Body
     2749                        Name    Type    Required?    Description
     2750                        type    string    yes    The subscription type name: channel.hype_train.progress.
     2751                        version    string    yes    The subscription type version: 1.
     2752                        condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to hype train progress notifications for.
     2753                        transport     transport     yes    Transport-specific parameters.
     2754                        Channel Hype Train Progress Webhook Example
     2755                        {
     2756                            "type": "channel.hype_train.progress",
     2757                            "version": "1",
     2758                            "condition": {
     2759                                "broadcaster_user_id": "1337"
     2760                            },
     2761                            "transport": {
     2762                                "method": "webhook",
     2763                                "callback": "https://example.com/webhooks/callback",
     2764                                "secret": "s3cRe7"
     2765                            }
     2766                        }
     2767                        Channel Hype Train Progress Notification Payload
     2768                        Name    Type    Description
     2769                        subscription     subscription     Subscription information.
     2770                        event     event     Event information. Contains hype train information like the level, goal, top contributors, last contribution, start time, and expiration time.
     2771                        Channel Hype Train Progress Notification Example
     2772                        {
     2773                            "subscription": {
     2774                                "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2775                                "type": "channel.hype_train.progress",
     2776                                "version": "1",
     2777                                "status": "enabled",
     2778                                "cost": 0,
     2779                                "condition": {
     2780                                    "broadcaster_user_id": "1337"
     2781                                },
     2782                                 "transport": {
     2783                                    "method": "webhook",
     2784                                    "callback": "https://example.com/webhooks/callback"
     2785                                },
     2786                                "created_at": "2019-11-16T10:11:12.123Z"
     2787                            },
     2788                            "event": {
     2789                                "broadcaster_user_id": "1337",
     2790                                "broadcaster_user_login": "cool_user",
     2791                                "broadcaster_user_name": "Cool_User",
     2792                                "level": 2,
     2793                                "total": 700,
     2794                                "progress": 200,
     2795                                "goal": 1000,
     2796                                "top_contributions": [
     2797                                    { "user_id": "123", "user_login": "pogchamp", "user_name": "PogChamp", "type": "bits", "total": 50 },
     2798                                    { "user_id": "456", "user_login": "kappa", "user_name": "Kappa", "type": "subscription", "total": 45 }
     2799                                ],
     2800                                "last_contribution": { "user_id": "123", "user_login": "pogchamp", "user_name": "PogChamp", "type": "bits", "total": 50 },
     2801                                "started_at": "2020-07-15T17:16:03.17106713Z",
     2802                                "expires_at": "2020-07-15T17:16:11.17106713Z"
     2803                            }
     2804                        }   */     
     2805                                 
     2806    }
     2807   
     2808    public function eventsub_hype_train_end() {
     2809        $call_authentication = 'channel:read:hype_train';
     2810        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2811        $method = 'POST';
     2812        $type = 'channel.hype_train.end';     
     2813       
     2814       
     2815               /*
     2816                Channel Hype Train End Request Body
     2817                Name    Type    Required?    Description
     2818                type    string    yes    The subscription type name: channel.hype_train.end.
     2819                version    string    yes    The subscription type version: 1.
     2820                condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to hype train end notifications for.
     2821                transport     transport     yes    Transport-specific parameters.
     2822                Channel Hype Train End Webhook Example
     2823                {
     2824                    "type": "channel.hype_train.end",
     2825                    "version": "1",
     2826                    "condition": {
     2827                        "broadcaster_user_id": "1337"
     2828                    },
     2829                    "transport": {
     2830                        "method": "webhook",
     2831                        "callback": "https://example.com/webhooks/callback",
     2832                        "secret": "s3cRe7"
     2833                    }
     2834                }
     2835                Channel Hype Train End Notification Payload
     2836                Name    Type    Description
     2837                subscription     subscription     Subscription information.
     2838                event     event     Event information. Contains hype train information like the level, top contributors, start time, end time, and cooldown end time.
     2839                Channel Hype Train End Notification Example
     2840                {
     2841                    "subscription": {
     2842                        "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2843                        "type": "channel.hype_train.end",
     2844                        "version": "1",
     2845                        "status": "enabled",
     2846                        "cost": 0,
     2847                        "condition": {
     2848                            "broadcaster_user_id": "1337"
     2849                        },
     2850                         "transport": {
     2851                            "method": "webhook",
     2852                            "callback": "https://example.com/webhooks/callback"
     2853                        },
     2854                        "created_at": "2019-11-16T10:11:12.123Z"
     2855                    },
     2856                    "event": {
     2857                        "broadcaster_user_id": "1337",
     2858                        "broadcaster_user_login": "cool_user",
     2859                        "broadcaster_user_name": "Cool_User",
     2860                        "level": 2,
     2861                        "total": 137,
     2862                        "top_contributions": [
     2863                            { "user_id": "123", "user_login": "pogchamp", "user_name": "PogChamp", "type": "bits", "total": 50 },
     2864                            { "user_id": "456", "user_login": "kappa", "user_name": "Kappa", "type": "subscription", "total": 45 }
     2865                        ],
     2866                        "started_at": "2020-07-15T17:16:03.17106713Z",
     2867                        "ended_at": "2020-07-15T17:16:11.17106713Z",
     2868                        "cooldown_ends_at": "2020-07-15T18:16:11.17106713Z"
     2869                    }
     2870                }   */     
     2871         
     2872    }
     2873   
     2874    public function eventsub_stream_online() {
     2875        $call_authentication = 'none';
     2876        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2877        $method = 'POST';
     2878        $type = 'stream.online';     
     2879       
     2880       
     2881                        /*
     2882                        Stream Online Request Body
     2883                        Name    Type    Required?    Description
     2884                        type    string    yes    The subscription type name: stream.online.
     2885                        version    string    yes    The subscription type version: 1.
     2886                        condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to get updates for.
     2887                        transport     transport     yes    Transport-specific parameters.
     2888                        Stream Online Webhook Example
     2889                        {
     2890                            "type": "stream.online",
     2891                            "version": "1",
     2892                            "condition": {
     2893                                "broadcaster_user_id": "1337"
     2894                            },
     2895                            "transport": {
     2896                                "method": "webhook",
     2897                                "callback": "https://example.com/webhooks/callback",
     2898                                "secret": "s3cRe7"
     2899                            }
     2900                        }
     2901                        Stream Online Notification Payload
     2902                        Name    Type    Description
     2903                        subscription     subscription     Subscription information.
     2904                        event     event     Event information. Contains the stream ID, broadcaster user ID, broadcaster user name, and the stream type.
     2905                        Stream Online Notification Example
     2906                        {
     2907                            "subscription": {
     2908                                "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2909                                "type": "stream.online",
     2910                                "version": "1",
     2911                                "status": "enabled",
     2912                                "cost": 0,
     2913                                "condition": {
     2914                                    "broadcaster_user_id": "1337"
     2915                                },
     2916                                 "transport": {
     2917                                    "method": "webhook",
     2918                                    "callback": "https://example.com/webhooks/callback"
     2919                                },
     2920                                "created_at": "2019-11-16T10:11:12.123Z"
     2921                            },
     2922                            "event": {
     2923                                "id": "9001",
     2924                                "broadcaster_user_id": "1337",
     2925                                "broadcaster_user_login": "cool_user",
     2926                                "broadcaster_user_name": "Cool_User",
     2927                                "type": "live",
     2928                                "started_at": "2020-10-11T10:11:12.123Z"
     2929                            }
     2930                        } */
     2931
     2932           
     2933    }
     2934   
     2935    public function eventsub_stream_offline() {
     2936        $call_authentication = 'none';
     2937        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2938        $method = 'POST';
     2939        $type = 'stream.offline';
     2940       
     2941            /*
     2942                    Stream Offline Request Body
     2943            Name    Type    Required?    Description
     2944            type    string    yes    The subscription type name: stream.offline.
     2945            version    string    yes    The subscription type version: 1.
     2946            condition     condition     yes    Subscription-specific parameters. Pass in the broadcaster user ID for the channel you want to get updates for.
     2947            transport     transport     yes    Transport-specific parameters.
     2948            Stream Offline Webhook Example
     2949            {
     2950                "type": "stream.offline",
     2951                "version": "1",
     2952                "condition": {
     2953                    "broadcaster_user_id": "1337"
     2954                },
     2955                "transport": {
     2956                    "method": "webhook",
     2957                    "callback": "https://example.com/webhooks/callback",
     2958                    "secret": "s3cRe7"
     2959                }
     2960            }
     2961            Stream Offline Notification Payload
     2962            Name    Type    Description
     2963            subscription     subscription     Subscription information.
     2964            event     event     Event information. Contains the broadcaster user ID and broadcaster user name.
     2965            Stream Offline Notification Example
     2966            {
     2967                "subscription": {
     2968                    "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     2969                    "type": "stream.offline",
     2970                    "version": "1",
     2971                    "status": "enabled",
     2972                    "cost": 0,
     2973                    "condition": {
     2974                        "broadcaster_user_id": "1337"
     2975                    },
     2976                    "created_at": "2019-11-16T10:11:12.123Z",
     2977                     "transport": {
     2978                        "method": "webhook",
     2979                        "callback": "https://example.com/webhooks/callback"
     2980                    }
     2981                },
     2982                "event": {
     2983                    "broadcaster_user_id": "1337",
     2984                    "broadcaster_user_login": "cool_user",
     2985                    "broadcaster_user_name": "Cool_User"
     2986                }
     2987            }     */   
     2988    }
     2989   
     2990    public function eventsub_user_authorization_revoke() {
     2991        $call_authentication = 'none'; // Provided client_id must match the client id in the application access token.
     2992        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     2993        $method = 'POST';
     2994        $type = 'user.authorization.revoke'; 
     2995       
     2996       
     2997        /*
     2998                User Authorization Revoke Request Body
     2999                Name    Type    Required?    Description
     3000                type    string    yes    The subscription type name: user.authorization.revoke.
     3001                version    string    yes    The subscription type version: 1.
     3002                condition     condition     yes    Subscription-specific parameters. Pass in the client ID of the application you want to get user authorization revoke notifications for.
     3003                transport     transport     yes    Transport-specific parameters.
     3004                User Authorization Revoke Webhook Example
     3005                {
     3006                    "type": "user.authorization.revoke",
     3007                    "version": "1",
     3008                    "condition": {
     3009                        "client_id": "1337"
     3010                    },
     3011                    "transport": {
     3012                        "method": "webhook",
     3013                        "callback": "https://example.com/webhooks/callback",
     3014                        "secret": "s3cRe7"
     3015                    }
     3016                }
     3017                User Authorization Revoke Notification Payload
     3018                Name    Type    Description
     3019                subscription     subscription     Subscription information.
     3020                event     event     Event information. Contains your application’s client ID and the user ID of the user who revoked authorization for your application.
     3021                User Authorization Revoke Notification Example
     3022                {
     3023                    "subscription": {
     3024                        "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     3025                        "type": "user.authorization.revoke",
     3026                        "version": "1",
     3027                        "status": "enabled",
     3028                        "cost": 0,
     3029                        "condition": {
     3030                            "client_id": "crq72vsaoijkc83xx42hz6i37"
     3031                        },
     3032                         "transport": {
     3033                            "method": "webhook",
     3034                            "callback": "https://example.com/webhooks/callback"
     3035                        },
     3036                        "created_at": "2019-11-16T10:11:12.123Z"
     3037                    },
     3038                    "event": {
     3039                        "client_id": "crq72vsaoijkc83xx42hz6i37",
     3040                        "user_id": "1337",
     3041                        "user_login": "cool_user",  // Null if the user no longer exists
     3042                        "user_name": "Cool_User"    // Null if the user no longer exists
     3043                    }
     3044                }  */           
     3045    }
     3046   
     3047    public function eventsub_user_update() {
     3048        $call_authentication = 'none'; // When using user:read:email scope, the notification will include email field.
     3049        $endpoint = 'https://api.twitch.tv/helix/eventsub/subscriptions';
     3050        $method = 'POST';
     3051        $type = 'user.update';   
     3052       
     3053       
     3054       
     3055        /*
     3056                User Update Request Body
     3057                Name    Type    Required?    Description
     3058                type    string    yes    The subscription type name: user.update.
     3059                version    string    yes    The subscription type version: 1.
     3060                condition     condition     yes    Subscription-specific parameters. Pass in the user ID for the user you want update notifications for.
     3061                transport     transport     yes    Transport-specific parameters.
     3062                User Update Webhook Example
     3063                {
     3064                    "type": "user.update",
     3065                    "version": "1",
     3066                    "condition": {
     3067                        "user_id": "1337"
     3068                    },
     3069                    "transport": {
     3070                        "method": "webhook",
     3071                        "callback": "https://example.com/webhooks/callback",
     3072                        "secret": "s3cRe7"
     3073                    }
     3074                }
     3075                User Update Notification Payload
     3076                Name    Type    Description
     3077                subscription     subscription     Subscription information.
     3078                event     event     Event information. Contains the user ID, user name, and description. The user’s email is included if you have the user:read:emailscope for the user.
     3079                User Update Notification Example
     3080                {
     3081                    "subscription": {
     3082                        "id": "f1c2a387-161a-49f9-a165-0f21d7a4e1c4",
     3083                        "type": "user.update",
     3084                        "version": "1",
     3085                        "status": "enabled",
     3086                        "cost": 0,
     3087                        "condition": {
     3088                           "user_id": "1337"
     3089                        },
     3090                         "transport": {
     3091                            "method": "webhook",
     3092                            "callback": "https://example.com/webhooks/callback"
     3093                        },
     3094                        "created_at": "2019-11-16T10:11:12.123Z"
     3095                    },
     3096                    "event": {
     3097                        "user_id": "1337",
     3098                        "user_login": "cool_user",
     3099                        "user_name": "Cool_User",
     3100                        "email": "[email protected]",  // Requires user:read:email scope
     3101                        "description": "cool description"
     3102                    }
     3103                }       
     3104        */   
     3105    }
    16713106}
    16723107
  • twitchpress/trunk/install.php

    r2488173 r2527323  
    5858    $wpdb->twitchpress_activity  = "{$wpdb->prefix}twitchpress_activity";
    5959    $wpdb->twitchpress_errors    = "{$wpdb->prefix}twitchpress_errors";
    60     $wpdb->twitchpress_outcomes  = "{$wpdb->prefix}twitchpress_outcomes";
    6160    $wpdb->twitchpress_endpoints = "{$wpdb->prefix}twitchpress_endpoints";
    6261    $wpdb->twitchpress_meta      = "{$wpdb->prefix}twitchpress_meta";   
  • twitchpress/trunk/loader.php

    r2494470 r2527323  
    169169     */
    170170    public function includes() {
    171                                                 
     171                                         
    172172        do_action( 'before_twitchpress_includes' );
    173173               
     
    186186        require_once( plugin_basename( 'includes/classes/class.twitchpress-set-main-channel-auth.php' ) );
    187187        //require_once( plugin_basename( 'includes/classes/class.twitchpress-set-bot-channel-auth.php' ) );
    188        
    189         // Systems...
    190         require_once( plugin_basename( 'systems/giveaways/class.twitchpress-giveaways.php' ) );
    191         //require_once( plugin_basename( 'systems/subscribers/class.twitchpress-subscribers.php' ) );
    192                                  
     188                         
    193189        // More classes...
     190        require_once( plugin_basename( 'systems/giveaways/class.twitchpress-giveaways.php' ) );       
     191        require_once( 'includes/admin/class.twitchpress-admin-notices.php' );       
    194192        require_once( 'includes/classes/class.twitchpress-current-user.php' );
    195193        require_once( 'includes/classes/class.twitchpress-posts-gate.php' );
     
    211209        require_once( plugin_basename( 'requests.php' ) );
    212210        require_once( 'includes/classes/class.twitchpress-listener-main-account-oauth.php' );
    213         require_once( 'includes/libraries/twitch/helix/class.twitch-webhooks.php' );
    214211        require_once( plugin_basename( 'includes/classes/class.twitchpress-public-preset-notices.php' ) );
    215212        require_once( 'includes/classes/class.twitchpress-custom-login-notices.php' );
    216213        require_once( 'includes/posts/class.twitchpress-page-template-splitscreen.php' );
    217214       
    218         // Include main class...
     215        // Include main API (all-api) class...
    219216        include_once( 'includes/libraries/allapi/class.all-api.php' );
    220217
    221         // Discord
     218        // Discord Integration
    222219        include_once( 'includes/libraries/allapi/discord/class.api-discord.php' ); 
    223220        include_once( 'includes/libraries/allapi/discord/class.api-discord-listener.php' );
    224221       
    225         // Streamlabs                                                
     222        // Streamlabs Integration
    226223        include_once( 'includes/libraries/allapi/streamlabs/functions.api-streamlabs.php' );   
    227224        include_once( 'includes/libraries/allapi/streamlabs/class.api-streamlabs.php' );
    228225        include_once( 'includes/libraries/allapi/streamlabs/class.api-streamlabs-listener.php' );
    229226   
    230         // YouTube
     227        // YouTube Integration
    231228        include_once( 'includes/libraries/allapi/youtube/functions.api-youtube.php' );   
    232229       
     
    251248    * or at all times by extensions.
    252249    *
    253     * @version 1.0
     250    * @version 2.0
    254251    */
    255252    private function load_core_objects() {
    256253        // Objects not required...
    257254        TwitchPress_Current_User_Setter::init(); /*adds values to $current_user*/
    258        
     255                         
    259256        // Create objects core objects...
    260257        if( class_exists( 'BugNet' ) ){ $this->bugnet = new BugNet(); }
     
    264261        $this->login          = new TwitchPress_Login();
    265262        $this->login_sc       = new TwitchPress_Login_by_Shortcode(); 
    266         $this->gate           = new TwitchPress_Posts_Gate();
    267         // See init_system() after adding new line...       
     263        $this->gate           = new TwitchPress_Posts_Gate();
     264        $this->admin_notices  = new TwitchPress_Admin_Notices();
     265
     266        # Hint: Go to function init_system() after adding new line here...       
    268267    }
    269268   
     
    346345    public function init_system() {
    347346                   
    348         // Before init action.
     347        // Before init action...
    349348        do_action( 'before_twitchpress_init' );   
    350349         
     
    358357        $this->login_sc->init();   
    359358        $this->gate->init();
     359        $this->admin_notices->init();
     360       
     361        if( isset( $this->webhooks ) ) { $this->webhooks->init(); }
    360362       
    361363        // Collect required scopes from extensions and establish system requirements.
     
    380382        add_filter( 'plugin_row_meta', 'twitchpress_plugin_row_meta', 10, 2 );
    381383
    382         $this->post_types();
     384        // Load the various systems, includes custom post types within those systems...
     385        $this->load_systems();
    383386       
    384387        // Init action.
     
    387390   
    388391    /**
    389     * Register custom post types and their taxonomies...
    390     *
    391     * @version 2.0
    392     */
    393     public function post_types() {
     392    * Load systems, including registration of custom post types...
     393    *
     394    * @version 2.1
     395    */
     396    public function load_systems() {
    394397       
    395398        // Channels - Core
     
    407410            require_once( 'includes/posts/class.twitchpress-post-type-perks.php' );
    408411            TwitchPress_Post_Type_Perks::init(); 
     412        }
     413       
     414        // Webhooks System
     415        if( get_option( 'twitchpress_webhooks_switch' ) == 'yes' ) {
     416           
     417            // Set the callback URL sent to Twitch.tv when subscribing to a webhook...
     418            $url = admin_url( 'admin-post.php?webhook=twitchpress_eventsub_notification' );
     419            if( !defined( 'TWITCHPRESS_WEBHOOK_CALLBACK' ) ) { define( 'TWITCHPRESS_WEBHOOK_CALLBACK', $url ); }
     420            unset( $url );
     421           
     422            require_once( 'includes/posts/class.twitchpress-post-type-webhooks.php' );             
     423            require_once( plugin_basename( 'systems/webhooks/class.twitchpress-webhooks-cache.php' ) );
     424            require_once( plugin_basename( 'systems/webhooks/class.twitchpress-webhooks-event-processing.php' ) );
     425           
     426            // Initiate the custom post-type...
     427            TwitchPress_Post_Type_Webhooks::init();
     428                     
     429            // Hook into init for single site, priority 0 = highest priority...
     430            add_action( 'init', 'twitchpress_integrate_wpdb_webhooksmeta', 0);
     431
     432            // Hook in to switch blog to support multisite...
     433            add_action( 'switch_blog', 'twitchpress_integrate_wpdb_webhooksmeta', 0 );
     434
     435            // Listen for Twitch.tv EventSub webhook notifications and store them in cache for processing later...
     436            add_action( 'admin_post_nopriv', 'twitchpress_webhooks_eventsub_listener', 1, 0 );
     437           
     438            // Background processing of webhook notifications that have been stored in cache...
     439            add_action( 'init', array( new TwitchPress_Webhooks_Event_Processing(), 'process_handler' ) );           
    409440        }       
    410441    }
  • twitchpress/trunk/pro/shortcodes/channellist/twitchpress-shortcode-channellist.css

    r2488173 r2527323  
    4242
    4343.col-lg {
    44   width: calc(100% - 80px);
     44  width: calc(100%-80px);
    4545}
    4646
  • twitchpress/trunk/pro/shortcodes/channellist/twitchpress-shortcode-channellist.php

    r2494470 r2527323  
    3333        $twitch_api = new TwitchPress_Twitch_API();
    3434        switch ( $this->atts['type'] ) {
    35            case 'team': # HELIX DOES NOT SUPPORT A TEAM ENDPOINT - LAST CHECKED MARCH 2021
     35           case 'team':
    3636                return false;
    3737             break;         
  • twitchpress/trunk/readme.txt

    r2496316 r2527323  
    66Tags: Twitch, Twitch.tv, Twitch Channel, Twitch Embed, Twitch Stream, Twitch API, TwitchPress
    77Requires at least: 5.4
    8 Tested up to: 5.6
    9 Stable tag: 3.12.0
     8Tested up to: 5.7
     9Stable tag: 3.13.0
    1010Requires PHP: 5.6
    1111                       
     
    102102== Changelog == 
    103103   
    104 = 3.12.0 UPGRADE Released ??? =
     104= 3.13.0 UPGRADE Released 6th May 2021 =
     105* New Features
     106    - Can now enter the main team name and the teams Twitch ID is obtained automatically
     107* Feature Changes
     108    - Webhooks option added to System switches in General Settings
     109    - Added a Content Gate checkbox for switching content gating on/off as a system
     110    - New options added to Edit Webhooks view for webhook type and the desirned action in WordPress
     111* Faults Resolved
     112    - PHP object as array error in function validate_user_token() avoided but the cause still to be determined.
     113    - Uninstallation - fixed issue with removal of admin users meta data
     114* Technical Notes
     115    - Removed Quick-Tool for installing Pro edition (pro was merged into the free download)
     116    - Removed description values from hidden fields in installation setts for BugNet
     117    - Created option twitchpress_gate_switch which now defines content gating as a system
     118    - Now that Twitch API Helix (version 6) is in full use, error logging needs to be better integrated
     119    - Removed API column from the Data view API Activity as the database table also had it removed
     120    - Further improvements made to API logging
     121    - File class.twitchpress-admin-notices.php is no longer loaded in class.twitchpress-admin.php because...
     122    - ...the class is being used in function twitchpress_user_sub_sync_single() which is used during login
     123    - ...it is now loaded in loader.php
     124    - Removed twitchpress_is_sync_due() from UM functions because it's use is vague and potentially preventing UM roles to be set
     125    - Added json_encode() for body value in class.twitchpress-curl.php (json_encode( $this->curl_request_body ))
     126    - Contents of class.twitch-webhooks.php moved and the file deleted
     127* Configuration Advice
     128    - Manually setup webhooks for Twitch subs to test the new webhooks system which includes a custom post type
     129* Database Changes
     130    - Added log entry "life" column to API activity table   
     131     
     132= 3.12.0 UPGRADE Released 15th March 2021 =
    105133* New Features
    106134    - BuddyPress Avatar Over-ride
    107135* Feature Changes
    108     - None
     136    - Uninstallation removes BugNet options data
    109137* Faults Resolved
    110138    - None
     
    332360
    333361== Contributors ==
    334 Donators, GitHub contributors and developers who support me when working on TwitchPress will be listed here.
     362List of developers and people who have supported development in a technical way...
    335363
    336364* nookyyy      - A popular Twitch.tv streamer who done half of the testing.
  • twitchpress/trunk/shortcodes.php

    r2494470 r2527323  
    2727function twitchpress_shortcode_init( $atts, $content = null ) {         
    2828    global $post;
    29    
     29                     
    3030    // Apply defaults to all shortcodes (a standard accross the entire site)
    3131    // Can trigger very different output if changed after page publication...
     
    6767            'scope'          => '',
    6868    ), $atts, 'twitchpress_shortcodes_advanced_' . $atts['shortcode'] );
    69    
     69                       
    7070    // Caching will be disabled for $content wrapping shortcodes...
    7171    if( $content ) { $atts['cache'] = true; }
    72    
     72                         
    7373    // Reduce cache time for admin to make site building easier...
    7474    if( current_user_can('administrator') ) {
    7575        $atts['cacheexpiry'] = 30;   
    7676    }
    77 
     77                           
    7878    // Complete the name of requested shortcode method...
    7979    $function_name = 'twitchpress_shortcode_' . $atts['shortcode'];
    80 
     80                           
    8181    // Establish channel ID when only the channel name has been provided...
    8282    if( isset( $atts['channel_name'] ) && !isset( $atts['channel_id'] ) ) {
     
    8787    // Output buffer is required for this design...                 
    8888    ob_start();
    89    
     89
    9090    // Return if cached HTML found...
    9191    $cache_name = 'twitchpress_shortcode_' . $atts['shortcode'] . '_' . $post->ID;
     
    923923* @version 1.0
    924924*/
    925 function twitchpress_shortcode_channel_list( $atts ) {             
     925function twitchpress_shortcode_channel_list( $atts ) {                                
    926926    require_once( TWITCHPRESS_PRO_DIR_PATH . 'shortcodes/channellist/twitchpress-shortcode-channellist.php' );   
    927     $shortcode_object = new TwitchPress_Shortcode_Channel_List();
     927    $shortcode_object = new TwitchPress_Shortcode_Channel_List(); 
    928928    $shortcode_object->atts = $atts;
    929     $shortcode_object->init();     
    930     return $shortcode_object->output();
     929    $shortcode_object->init();        
     930    return $shortcode_object->output();   
    931931}
    932932
  • twitchpress/trunk/twitchpress.php

    r2496316 r2527323  
    55 * Github URI: https://github.com/RyanBayne/TwitchPress
    66 * Description: Add the power of Twitch.tv to WordPress
    7  * Version: 3.12.0
     7 * Version: 3.13.0
    88 * Author: Ryan Bayne
    99 * Author URI: https://ryanbayne.wordpress.com/
    1010 * Requires at least: 5.4
    11  * Tested up to: 5.6
     11 * Tested up to: 5.7
    1212 * License: GPL3
    1313 * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
     
    1515 */
    1616 
    17 const TWITCHPRESS_VERSION = '3.12.0';
     17const TWITCHPRESS_VERSION = '3.13.0';
    1818
    1919// Exit if accessed directly.
  • twitchpress/trunk/uninstall.php

    r2496316 r2527323  
    3232* @version 2.0
    3333*/
    34 function twitchpress_remove_options() {     
    35    
    36     /*  Add this approach when working on uninstallation and improving cleanup...
    37     // Include settings so that we can run through defaults
    38     include_once( TWITCHPRESS_PLUGIN_DIR_PATH . 'includes/admin/class.twitchpress-admin-settings.php' );
    39     $settings = TwitchPress_Admin_Settings::get_settings_pages();
    40 
    41     foreach ( $settings as $section ) {
    42         if ( !method_exists( $section, 'get_settings' ) ) {
    43             continue;
    44         }
    45        
    46         $subsections = array_unique( array_merge( array( '' ), array_keys( $section->get_sections() ) ) );
    47 
    48         foreach ( $subsections as $subsection ) {
    49             foreach ( $section->get_settings( $subsection ) as $value ) {
    50                 if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
    51                     $autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true;
    52                     add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
    53                 }
    54             }
    55         }
    56     } */
    57    
     34function twitchpress_remove_options() {         
    5835    delete_option( 'twitchpress_admin_notices' );
    5936    delete_option( 'twitchpress_admin_notice_missingvaluesofferwizard' );
     
    130107    delete_option( 'twitchpress_visitor_scope_viewing_activity_read' );
    131108    delete_option( 'twitchpress_buddypress_avatars_override' );
    132    
     109    delete_option( 'twitchpress_twitchpress-embed-everything_settings' );       
     110    delete_option( 'twitchpress_twitchpress-login-extension_settings' );       
     111    delete_option( 'twitchpress_twitchpress-sync-extension_settings' );       
     112    delete_option( 'twitchpress_twitchpress-um-extension_settings' );
     113
     114    // BugNet   
     115    delete_option( 'bugnet_activate_events' );       
     116    delete_option( 'bugnet_activate_log' );       
     117    delete_option( 'bugnet_activate_tracing' );       
     118    delete_option( 'bugnet_levelswitch_emergency' );       
     119    delete_option( 'bugnet_levelswitch_alert' );       
     120    delete_option( 'bugnet_levelswitch_critical' );       
     121    delete_option( 'bugnet_levelswitch_error' );       
     122    delete_option( 'bugnet_levelswitch_warning' );       
     123    delete_option( 'bugnet_levelswitch_notice' );       
     124    delete_option( 'bugnet_handlerswitch_email' );       
     125    delete_option( 'bugnet_handlerswitch_logfiles' );       
     126    delete_option( 'bugnet_handlerswitch_restapi' );       
     127    delete_option( 'bugnet_handlerswitch_tracing' );       
     128    delete_option( 'bugnet_handlerswitch_wpdb' );       
     129    delete_option( 'bugnet_reportsswitch_dailysummary' );       
     130    delete_option( 'bugnet_reportsswitch_eventsnapshot' );       
     131    delete_option( 'bugnet_reportsswitch_tracecomplete' );       
     132    delete_option( 'bugnet_systemlogging_switch' );       
     133    delete_option( 'bugnet_error_dump_user_id' );
     134
    133135    // Deprecated
    134136    delete_option( 'twitchress_sandbox_mode_falsereturns_switch' );
     
    155157    $activity  = "{$wpdb->prefix}twitchpress_activity";
    156158    $errors    = "{$wpdb->prefix}twitchpress_errors";
    157     $outcomes  = "{$wpdb->prefix}twitchpress_outcomes";
    158159    $endpoints = "{$wpdb->prefix}twitchpress_endpoints";
    159160    $meta      = "{$wpdb->prefix}twitchpress_meta";   
     
    161162    $wpdb->query( "DROP TABLE IF EXISTS $activity" );
    162163    $wpdb->query( "DROP TABLE IF EXISTS $errors" );
    163     $wpdb->query( "DROP TABLE IF EXISTS $outcomes" );
    164164    $wpdb->query( "DROP TABLE IF EXISTS $endpoints" );
    165165    $wpdb->query( "DROP TABLE IF EXISTS $meta" );
     
    186186*/
    187187function twitchpress_remove_user_data() {
    188     delete_user_meta( 'twitchpress_twitch_sub' );
    189     delete_user_meta( 'twitchpress_avatar_url' );
    190     delete_user_meta( 'twitchpress_twitch_logo_url' );
    191     delete_user_meta( 'twitchpress_twitch_logo_attachment_id' );
    192     delete_user_meta( 'twitchpress_code' );
    193     delete_user_meta( 'twitchpress_token' );
    194     delete_user_meta( 'twitchpress_twitch_id' );
    195     delete_user_meta( 'twitchpress_twitch_bot_id' );
    196     delete_user_meta( 'twitchpress_bot_code' );
    197     delete_user_meta( 'twitchpress_auth_time' );
    198     delete_user_meta( 'twitchpress_bot_token' );
    199     delete_user_meta( 'twitchpress_token_scope' );
    200     delete_user_meta( 'twitchpress_token_refresh' );
    201     delete_user_meta( 'twitchpress_bot_token_refresh' );
    202     delete_user_meta( 'twitchpress_twitch_expires_in' );
    203     delete_user_meta( 'twitchpress_sync_time' );
    204     delete_user_meta( 'twitchpress_twitch_bio' );
    205     delete_user_meta( 'twitchpress_twitch_email' );
    206     delete_user_meta( 'twitchpress_streamlabs_code' );
    207     delete_user_meta( 'twitchpress_streamlabs_access_token' );
    208     delete_user_meta( 'twitchpress_streamlabs_expires_in' );
    209     delete_user_meta( 'twitchpress_streamlabs_refresh_token' );
    210     delete_user_meta( 'twitchpress_streamlabs_scope' );
     188    delete_user_meta( 1, 'twitchpress_twitch_sub' );
     189    delete_user_meta( 1, 'twitchpress_avatar_url' );
     190    delete_user_meta( 1, 'twitchpress_twitch_logo_url' );
     191    delete_user_meta( 1, 'twitchpress_twitch_logo_attachment_id' );
     192    delete_user_meta( 1, 'twitchpress_code' );
     193    delete_user_meta( 1, 'twitchpress_token' );
     194    delete_user_meta( 1, 'twitchpress_twitch_id' );
     195    delete_user_meta( 1, 'twitchpress_twitch_bot_id' );
     196    delete_user_meta( 1, 'twitchpress_bot_code' );
     197    delete_user_meta( 1, 'twitchpress_auth_time' );
     198    delete_user_meta( 1, 'twitchpress_bot_token' );
     199    delete_user_meta( 1, 'twitchpress_token_scope' );
     200    delete_user_meta( 1, 'twitchpress_token_refresh' );
     201    delete_user_meta( 1, 'twitchpress_bot_token_refresh' );
     202    delete_user_meta( 1, 'twitchpress_twitch_expires_in' );
     203    delete_user_meta( 1, 'twitchpress_sync_time' );
     204    delete_user_meta( 1, 'twitchpress_twitch_bio' );
     205    delete_user_meta( 1, 'twitchpress_twitch_email' );
     206    delete_user_meta( 1, 'twitchpress_streamlabs_code' );
     207    delete_user_meta( 1, 'twitchpress_streamlabs_access_token' );
     208    delete_user_meta( 1, 'twitchpress_streamlabs_expires_in' );
     209    delete_user_meta( 1, 'twitchpress_streamlabs_refresh_token' );
     210    delete_user_meta( 1, 'twitchpress_streamlabs_scope' );
    211211}
    212212
Note: See TracChangeset for help on using the changeset viewer.