Skip to content

Commit 4ff5aa9

Browse files
committed
Syntax highlighting on README.md
1 parent 1213eb6 commit 4ff5aa9

File tree

1 file changed

+66
-56
lines changed

1 file changed

+66
-56
lines changed

README.md

Lines changed: 66 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -14,105 +14,115 @@ Currently will not consider adding OAuth endpoints. (those required "authorized
1414
## Install
1515
Example composer.json
1616

17-
{
18-
"name": "MyCoolProject",
19-
"require": {
20-
"madcoda/php-youtube-api" : "dev-master"
21-
}
17+
```json
18+
{
19+
"name": "MyCoolProject",
20+
"require": {
21+
"madcoda/php-youtube-api" : "dev-master"
2222
}
23+
}
24+
```
2325

2426
Run the Install
2527

26-
composer install
27-
28-
//run "composer update" instead if you already has a composer.json before
29-
composer update
28+
```bash
29+
$ composer install
3030

31+
# Run "composer update" instead if you already has a composer.json before
32+
$ composer update
33+
```
3134

3235
## Usage (Plain PHP project)
3336

34-
require 'vendor/autoload.php';
35-
36-
$youtube = new Madcoda\Youtube(array('key' => '/* Your API key here */'));
37+
```php
38+
require 'vendor/autoload.php';
3739

38-
// Return a std PHP object
39-
$video = $youtube->getVideoInfo('rie-hPVJ7Sw');
40+
$youtube = new Madcoda\Youtube(array('key' => '/* Your API key here */'));
4041

41-
// Search playlists, channels and videos, Return an array of PHP objects
42-
$results = $youtube->search('Android');
42+
// Return a std PHP object
43+
$video = $youtube->getVideoInfo('rie-hPVJ7Sw');
4344

44-
// Search only Videos, Return an array of PHP objects
45-
$videoList = $youtube->searchVideos('Android');
45+
// Search playlists, channels and videos, Return an array of PHP objects
46+
$results = $youtube->search('Android');
4647

47-
// Search only Videos in a given channel, Return an array of PHP objects
48-
$videoList = $youtube->searchChannelVideos('keyword', 'UCk1SpWNzOs4MYmr0uICEntg', 100);
48+
// Search only Videos, Return an array of PHP objects
49+
$videoList = $youtube->searchVideos('Android');
4950

50-
$results = $youtube->searchAdvanced(array( /* params */ ));
51+
// Search only Videos in a given channel, Return an array of PHP objects
52+
$videoList = $youtube->searchChannelVideos('keyword', 'UCk1SpWNzOs4MYmr0uICEntg', 100);
5153

52-
// Return a std PHP object
53-
$channel = $youtube->getChannelByName('xdadevelopers');
54+
$results = $youtube->searchAdvanced(array( /* params */ ));
5455

55-
// Return a std PHP object
56-
$channel = $youtube->getChannelById('UCk1SpWNzOs4MYmr0uICEntg');
56+
// Return a std PHP object
57+
$channel = $youtube->getChannelByName('xdadevelopers');
5758

58-
// Return a std PHP object
59-
$playlist = $youtube->getPlaylistById('PL590L5WQmH8fJ54F369BLDSqIwcs-TCfs');
59+
// Return a std PHP object
60+
$channel = $youtube->getChannelById('UCk1SpWNzOs4MYmr0uICEntg');
6061

61-
// Return an array of PHP objects
62-
$playlists = $youtube->getPlaylistsByChannelId('UCk1SpWNzOs4MYmr0uICEntg');
62+
// Return a std PHP object
63+
$playlist = $youtube->getPlaylistById('PL590L5WQmH8fJ54F369BLDSqIwcs-TCfs');
6364

64-
// Return an array of PHP objects
65-
$playlistItems = $youtube->getPlaylistItemsByPlaylistId('PL590L5WQmH8fJ54F369BLDSqIwcs-TCfs');
65+
// Return an array of PHP objects
66+
$playlists = $youtube->getPlaylistsByChannelId('UCk1SpWNzOs4MYmr0uICEntg');
6667

67-
// Return an array of PHP objects
68-
$activities = $youtube->getActivitiesByChannelId('UCk1SpWNzOs4MYmr0uICEntg');
68+
// Return an array of PHP objects
69+
$playlistItems = $youtube->getPlaylistItemsByPlaylistId('PL590L5WQmH8fJ54F369BLDSqIwcs-TCfs');
6970

70-
// Parse Youtube URL into videoId
71-
$videoId = $youtube->parseVIdFromURL('https://www.youtube.com/watch?v=moSFlvxnbgk');
72-
// result: moSFlvxnbgk
71+
// Return an array of PHP objects
72+
$activities = $youtube->getActivitiesByChannelId('UCk1SpWNzOs4MYmr0uICEntg');
7373

74+
// Parse Youtube URL into videoId
75+
$videoId = $youtube->parseVIdFromURL('https://www.youtube.com/watch?v=moSFlvxnbgk');
76+
// result: moSFlvxnbgk
77+
```
7478

7579
## Usage (Laravel Project)
7680
Add the dependency in the composer.json, then run
7781

78-
composer update
82+
```bash
83+
$ composer update
84+
```
7985

8086
Since the Laravel framework also configured to autoload composer dependencies (in bootstrap/autoload.php),
8187
You don't need to add any require or include statements, just use the class
8288

8389
app/controllers/YoutubeController.php
8490

85-
class YoutubeController extends BaseController {
86-
87-
public function index()
88-
{
89-
$youtube = new Madcoda\Youtube(array('key' => '/* Your API key here */'));
90-
91-
print_r($youtube->getVideoInfo(Input::get('vid')));
92-
}
91+
```php
92+
class YoutubeController extends BaseController {
9393

94+
public function index()
95+
{
96+
$youtube = new Madcoda\Youtube(array('key' => '/* Your API key here */'));
97+
print_r($youtube->getVideoInfo(Input::get('vid')));
9498
}
9599

100+
}
101+
```
102+
96103
If you want to use this class as "Youtube", you can add an aliases, edit the app/config/app.php,
97104
Insert the following line:
98105

99-
'aliases' => array(
100-
...
101-
102-
'Youtube' => 'Madcoda\Youtube',
103-
),
104-
106+
```php
107+
'aliases' => array(
108+
//...
109+
'Youtube' => 'Madcoda\Youtube',
110+
),
111+
```
105112

106113
## Run Unit Test
107114
If you have PHPUnit installed in your environment, just run
108115

109-
$ phpunit
116+
```bash
117+
$ phpunit
118+
```
110119

111120
If you don't have PHPUnit installed, you can run this
112121

113-
$ composer update
114-
$ ./vendor/bin/phpunit
115-
122+
```bash
123+
$ composer update
124+
$ ./vendor/bin/phpunit
125+
```
116126

117127
## Format of returned data
118128
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
125135

126136
## Contact
127137
For bugs, complain and suggestions please [file an Issue here](https://github.com/madcoda/php-youtube-api/issues)
128-
or send email to jason@madcoda.com :)
138+
or send email to jason@madcoda.com :)

0 commit comments

Comments
 (0)