YouTube API For Your Website/Blog

This article will show you how to install youtube API for your website or blog. 

 

English Tutorial : https://youtu.be/xL2ivAM0lD0
Arabic Tutorial  :  https://youtu.be/f5z_axUxp_k
 

Part A: Installation

To install youtube API,Save this code in new PHP file, include it in your website : 

 <?php

//check https://khalil-shreateh.com/khalil.shtml/social_applications/youtube-applications/13-youtube-api-for-your-website-blog.html for variables informations .

$cid="";
$total="";
$rand="";
$randfrom="";
$width="";
$align="";

// javascript variables
$theme="";
$animation="";
$close_animation="";

$url="https://khalil-shreateh.com/Applications/Youtube-API/?cid=$cid&total=$total&rand=$rand&randfrom=$randfrom&width=$width&align=$align&theme=$theme&animation=$animation&close_animation=$close_animation";
$ctx = stream_context_create(array('http'=>
    array(
        'timeout' => 1,
    )
));
echo file_get_contents($url, false, $ctx);


?>

 

- API variables should sent after "?" , separated by "&"

- Custom $url variables depend on your need, check Part B  . 

 

Part B: Varialbes

Youtube API Variables
Variable Information Demo
cid Youtube Channel ID, Click here to get it yours .
Default value: UCQ9MDlV6uH6II8iQiESpBWg
Demo
total Total video to display, number between (1-5) . 
Default value: 1, Maximum Videos: 5. (contact me for more)
Demo
randfrom

To choose videos from your latest upload. for example: if you set total = 3, randomfrom = 10, the API will pick up random 3 videos from your latest 10 videos . 
Default value: 50

Demo
width Display width . 
Default value = 200px
Demo
align Set "align" to "h" if you want to display videos horizontally. Demo
rand Set "rand" to "off" if you want to display channel latest videos  . 
Default value: random
Demo
 
Javascript Display Variables
Variable Information Demo
theme Available themes: (white, black, hololight, holodark, supervan) . 
Default value: black
Demo
animation Available animations:(right, left, bottom, top, rotate, none, opacity, scale, zoom, scaley, scalex, rotatey, rotatex) . 
Default value: rotate
Demo
close_animation

Available animations:(right, left, bottom, top, rotate, none, opacity, scale, zoom, scaley, scalex, rotatey, rotatex) . 
Default value: scaley

Demo

Share your comment publicly
 

Copyright © 2017. All Rights Reserved. Created by khalil-shreateh.com.