gl_get_counter_youtube
Function get Subscriber Counter for Youtube.
Description
gl_get_counter_youtube( $user );
Parameters (1)
- 0. $user
- The user.
Usage
if ( !function_exists( 'gl_get_counter_youtube' ) ) { require_once '/admin/shortcode.php'; } // The user. $user = null; // NOTICE! Understand what this does before running. $result = gl_get_counter_youtube($user);
Defined (1)
The function is defined in the following location(s).
- /admin/shortcode.php
- function gl_get_counter_youtube($user) {
- $CHECK_URL_PREFIX = 'https://gdata.youtube.com/feeds/api/users/';
- $check_url = $CHECK_URL_PREFIX . $user . '?alt=json';
- try {
- $response = file_get_contents( $check_url );
- $result = json_decode( $response, true );
- if (isset( $result['entry']['yt$statistics']['subscriberCount'] )) {
- return gl_get_number_format( $result['entry']['yt$statistics']['subscriberCount'] );
- }
- else {
- return "0";
- }
- } catch ( Exception $e ) {
- return "0";
- }
- }