From 4ff5aa9b355a20280fea29078acfa004180b815f Mon Sep 17 00:00:00 2001 From: Maxime Horcholle Date: Sun, 8 Jun 2014 14:30:11 +0200 Subject: [PATCH] Syntax highlighting on README.md --- README.md | 122 +++++++++++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 9758f80..1a5e27b 100644 --- a/README.md +++ b/README.md @@ -14,105 +14,115 @@ Currently will not consider adding OAuth endpoints. (those required "authorized ## Install Example composer.json - { - "name": "MyCoolProject", - "require": { - "madcoda/php-youtube-api" : "dev-master" - } +```json +{ + "name": "MyCoolProject", + "require": { + "madcoda/php-youtube-api" : "dev-master" } +} +``` Run the Install - composer install - - //run "composer update" instead if you already has a composer.json before - composer update +```bash +$ composer install +# Run "composer update" instead if you already has a composer.json before +$ composer update +``` ## Usage (Plain PHP project) - require 'vendor/autoload.php'; - - $youtube = new Madcoda\Youtube(array('key' => '/* Your API key here */')); +```php +require 'vendor/autoload.php'; - // Return a std PHP object - $video = $youtube->getVideoInfo('rie-hPVJ7Sw'); +$youtube = new Madcoda\Youtube(array('key' => '/* Your API key here */')); - // Search playlists, channels and videos, Return an array of PHP objects - $results = $youtube->search('Android'); +// Return a std PHP object +$video = $youtube->getVideoInfo('rie-hPVJ7Sw'); - // Search only Videos, Return an array of PHP objects - $videoList = $youtube->searchVideos('Android'); +// Search playlists, channels and videos, Return an array of PHP objects +$results = $youtube->search('Android'); - // Search only Videos in a given channel, Return an array of PHP objects - $videoList = $youtube->searchChannelVideos('keyword', 'UCk1SpWNzOs4MYmr0uICEntg', 100); +// Search only Videos, Return an array of PHP objects +$videoList = $youtube->searchVideos('Android'); - $results = $youtube->searchAdvanced(array( /* params */ )); +// Search only Videos in a given channel, Return an array of PHP objects +$videoList = $youtube->searchChannelVideos('keyword', 'UCk1SpWNzOs4MYmr0uICEntg', 100); - // Return a std PHP object - $channel = $youtube->getChannelByName('xdadevelopers'); +$results = $youtube->searchAdvanced(array( /* params */ )); - // Return a std PHP object - $channel = $youtube->getChannelById('UCk1SpWNzOs4MYmr0uICEntg'); +// Return a std PHP object +$channel = $youtube->getChannelByName('xdadevelopers'); - // Return a std PHP object - $playlist = $youtube->getPlaylistById('PL590L5WQmH8fJ54F369BLDSqIwcs-TCfs'); +// Return a std PHP object +$channel = $youtube->getChannelById('UCk1SpWNzOs4MYmr0uICEntg'); - // Return an array of PHP objects - $playlists = $youtube->getPlaylistsByChannelId('UCk1SpWNzOs4MYmr0uICEntg'); +// Return a std PHP object +$playlist = $youtube->getPlaylistById('PL590L5WQmH8fJ54F369BLDSqIwcs-TCfs'); - // Return an array of PHP objects - $playlistItems = $youtube->getPlaylistItemsByPlaylistId('PL590L5WQmH8fJ54F369BLDSqIwcs-TCfs'); +// Return an array of PHP objects +$playlists = $youtube->getPlaylistsByChannelId('UCk1SpWNzOs4MYmr0uICEntg'); - // Return an array of PHP objects - $activities = $youtube->getActivitiesByChannelId('UCk1SpWNzOs4MYmr0uICEntg'); +// Return an array of PHP objects +$playlistItems = $youtube->getPlaylistItemsByPlaylistId('PL590L5WQmH8fJ54F369BLDSqIwcs-TCfs'); - // Parse Youtube URL into videoId - $videoId = $youtube->parseVIdFromURL('https://www.youtube.com/watch?v=moSFlvxnbgk'); - // result: moSFlvxnbgk +// Return an array of PHP objects +$activities = $youtube->getActivitiesByChannelId('UCk1SpWNzOs4MYmr0uICEntg'); +// Parse Youtube URL into videoId +$videoId = $youtube->parseVIdFromURL('https://www.youtube.com/watch?v=moSFlvxnbgk'); +// result: moSFlvxnbgk +``` ## Usage (Laravel Project) Add the dependency in the composer.json, then run - composer update +```bash +$ composer update +``` Since the Laravel framework also configured to autoload composer dependencies (in bootstrap/autoload.php), You don't need to add any require or include statements, just use the class app/controllers/YoutubeController.php - class YoutubeController extends BaseController { - - public function index() - { - $youtube = new Madcoda\Youtube(array('key' => '/* Your API key here */')); - - print_r($youtube->getVideoInfo(Input::get('vid'))); - } +```php +class YoutubeController extends BaseController { + public function index() + { + $youtube = new Madcoda\Youtube(array('key' => '/* Your API key here */')); + print_r($youtube->getVideoInfo(Input::get('vid'))); } +} +``` + If you want to use this class as "Youtube", you can add an aliases, edit the app/config/app.php, Insert the following line: - 'aliases' => array( - ... - - 'Youtube' => 'Madcoda\Youtube', - ), - +```php +'aliases' => array( + //... + 'Youtube' => 'Madcoda\Youtube', +), +``` ## Run Unit Test If you have PHPUnit installed in your environment, just run - $ phpunit +```bash +$ phpunit +``` If you don't have PHPUnit installed, you can run this - $ composer update - $ ./vendor/bin/phpunit - +```bash +$ composer update +$ ./vendor/bin/phpunit +``` ## Format of returned data The returnd json is decoded as PHP objects (not Array). @@ -125,4 +135,4 @@ Please read the ["Reference" section](https://developers.google.com/youtube/v3/d ## Contact For bugs, complain and suggestions please [file an Issue here](https://github.com/madcoda/php-youtube-api/issues) -or send email to jason@madcoda.com :) \ No newline at end of file +or send email to jason@madcoda.com :)