Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Chris

    (@zenation)

    Hi,
    an example could be this https://www.ads-software.com/plugins/related-youtube-videos/other_notes/ up to the part where it says

    /* Search YouTube. */
      $results  = $RytvAPI->searchYouTube( $data );

    $results will already be an array you can work with.

    I would also recommend playing a bit with the plugin settings for the “Cache Time (in hours)”. Increasing the default from 24h up to 72h (or even higher if you like) can decrease the number of API calls drastically!

    And finally, I’m still not sure how costly it actually is when you’ve reached the free limit (for I haven’t met that number yet). But my guess is that they won’t charge thaaat much. Those kinds of (scaling) web services tend to calculate pretty fair compared to fixed-price-package-deals. And if your sites hits that traffic you should think about monetizing it anyway $$$ ??

    Thread Starter yahood

    (@yahood)

    Thanks for your answer Sir ??

    But i still confuse how to configure for example i have 10 number of API youtube V3, then how to write it down to the your plugins php.

    Yes, thanks for the other solution. I still increasing the number of cache time ??

    i just afraid if my api will die anytime and everything will blank suddenly ?? So i think to get many API.

    Plugin Author Chris

    (@zenation)

    Hi,
    you don’t have to (or should) change the plugin code. Instead you might implement your own API and array handling code, e.g., in one of your theme files.

    And I’m actual hoping that when the free limit has been reached and you (or I) haven’t setup a paid account, everything will be blank. This would be much nicer than showing such an annoying error image like they did when turning off the API v2 support.

    Thread Starter yahood

    (@yahood)

    Sir, please help me to make a code php for array the api key for youtube related video plugins.

    My api key always limit no more than 1 day. I use it for my movie/mp3 site.. I have to change it daily because it looks blank ??

    Thank you very much.. It is very important to include array API KEY to prevent this condition. I don;t know how to implement array api key code in php to your plugin Sir. Thank you

    Thread Starter yahood

    (@yahood)

    <?php
    /* Load Youtube API Valid */
    if( !class_exists( 'RelatedYouTubeVideos_API' ) ) {
      $file = str_replace( '/', DIRECTORY_SEPARATOR, ABSPATH ) . 'lib' . DIRECTORY_SEPARATOR . 'RelatedYouTubeVidoes' . DIRECTORY_SEPARATOR . 'API.php';
      if( file_exists( $file ) ) {
        include_once $file;
      }
    }
    
    /* Do it, kalau API Video Valid */
    if( class_exists( 'RelatedYouTubeVideos_API' ) ) {
    $kunci = $mykeyword;

    how to implement to this code

    Plugin Author Chris

    (@zenation)

    To set the API key in the PHP code you have to do a little work around. Eg something like this:

    /* Load the "Related YouTube Videos" API class if it does not exist yet. */
    if( !class_exists( 'RelatedYouTubeVideos_API' ) ) {
    
      $file = str_replace( '/', DIRECTORY_SEPARATOR, ABSPATH . 'wp-content/plugins/related-youtube-videos/lib/RelatedYouTubeVideos/API.php' );
    
      if( file_exists( $file ) ) {
    
        include_once $file;
    
      }
    
    }
    /* This is a little dirty workaround (for now) for setting the API key manually */
    if( !class_exists( 'RelatedYouTubeVideos_CustomAPI' ) ) {
    
      class RelatedYouTubeVideos_CustomAPI extends RelatedYouTubeVideos_API {
    
        public function __construct( $apiKey ) {
    
          parent::__construct();
    
          $this->apiKey = $apiKey;
    
        }
    
      }
    
    }
    
    /* Only continue if the API class could be loaded properly. */
    if( class_exists( 'RelatedYouTubeVideos_API' ) ) {
    
      // ############ Set your API key
      $apiKey = '';
    
      $CustomRytvAPI  = new RelatedYouTubeVideos_CustomAPI( $apiKey );
    
      /* Do your configuration */
      $data = $CustomRytvAPI->validateConfiguration(
        array(
          'relation'  => 'keywords',
          'terms'     => 'monty python',
          'max'       => 3,
          'width'     => 150,
          'height'    => 150
        )
      );
    
      /* Search YouTube. */
      $videos_array = $CustomRytvAPI->searchYouTube( $data );
    
      // Delete the following line when going live! It's just for the sake of demonstration.
      var_dump( $videos_array );exit;
    
    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Make array of Youtube API’ is closed to new replies.