gl_get_counter_youtube

Function get Subscriber Counter for Youtube.

Description

gl_get_counter_youtube( $user ); 

Parameters (1)

0. $user
The user.

Usage

  1. if ( !function_exists( 'gl_get_counter_youtube' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-locker-for-wordpress/admin/shortcode.php'; 
  3.  
  4. // The user. 
  5. $user = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = gl_get_counter_youtube($user); 
  9.  

Defined (1)

The function is defined in the following location(s).

/admin/shortcode.php  
  1. function gl_get_counter_youtube($user) { 
  2.  
  3. $CHECK_URL_PREFIX = 'https://gdata.youtube.com/feeds/api/users/'; 
  4.  
  5. $check_url = $CHECK_URL_PREFIX . $user . '?alt=json'; 
  6.  
  7. try { 
  8. $response = file_get_contents( $check_url ); 
  9. $result = json_decode( $response, true ); 
  10.  
  11. if (isset( $result['entry']['yt$statistics']['subscriberCount'] )) { 
  12. return gl_get_number_format( $result['entry']['yt$statistics']['subscriberCount'] ); 
  13. else { 
  14. return "0"; 
  15. } catch ( Exception $e ) { 
  16. return "0";