PHP Classes

File: example/base.php

Recommend this page to a friend!
  Classes of Unused   Little YouTube PHP   example/base.php   Download  
File: example/base.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Little YouTube PHP
Search and get data from YouTube videos
Author: By
Last change: Fix channel, playlist, and add a notice
Date: 6 years ago
Size: 1,169 bytes
 

Contents

Class file image Download
<?php
   
//require_once __DIR__."/../vendor/autoload.php";
   
require_once __DIR__."/../LittleYoutube.php";
    use \
ScarletsFiction\LittleYoutube;
   
$error = '';

    if(isset(
$_REQUEST['video'])){
       
$video = LittleYoutube::video($_REQUEST['video'], ["temporaryDirectory"=>realpath(__DIR__."/temp")]);
       
$error .= $video->error."\n";
       
print_r(json_encode(["data"=>$video->data, "picture"=>$video->getImage(), "error"=>$error]));
    }

    if(isset(
$_REQUEST['channel'])){
       
$channel = LittleYoutube::channel($_REQUEST['channel'], ["temporaryDirectory"=>realpath(__DIR__."/temp")]);
       
$error .= $channel->error."\n";
       
print_r(json_encode(["data"=>$channel->data, "error"=>$error]));
    }

    if(isset(
$_REQUEST['playlist'])){
       
$playlist = LittleYoutube::playlist($_REQUEST['playlist'], ["temporaryDirectory"=>realpath(__DIR__."/temp")]);
       
$error .= $playlist->error."\n";
       
print_r(json_encode(["data"=>$playlist->data, "error"=>$error]));
    }

    if(isset(
$_REQUEST['search'])){
       
$search = LittleYoutube::search($_REQUEST['search'], ["temporaryDirectory"=>realpath(__DIR__."/temp")]);
       
$error .= $search->error."\n";
       
print_r(json_encode(["data"=>$search->data, "error"=>$error]));
    }