Skip to content

Commit

Permalink
Fixed my silly mistake at Youtube.php
Browse files Browse the repository at this point in the history
  • Loading branch information
muiton committed Jul 13, 2018
1 parent 7cee0a9 commit 40b2dde
Showing 1 changed file with 129 additions and 65 deletions.
194 changes: 129 additions & 65 deletions src/YouTube.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,71 +17,135 @@ public function __construct($key) {

}

public function chart($maxResults, $token = null) {

$params = array(
'chart' => 'mostPopular',
'type' => 'video',
'part' => 'id',
'order' => 'relevance',
'maxResults' => $maxResults
);

if (!is_null($token)) {
$params['pageToken'] = $token;
}

$out = self::api_get($this->endPoint['search'], $params);

foreach($out->items as $o) {
$ids[] = $o->id->videoId;
}

if (isset($out->prevPageToken)) {
$info['page_info']['prevPage'] = $out->prevPageToken;
}
if (isset($out->nextPageToken)) {
$info['page_info']['nextPage'] = $out->nextPageToken;
}

$info['content'] = self::formatVideos($ids);

return $info;

}

public function videoByCat($catID, $maxResults, $token = null) {

$params = array(
'videoCategoryId' => $catID,
'type' => 'video',
'part' => 'id',
'order' => 'relevance',
'maxResults' => $maxResults
);

if (!is_null($token)) {
$params['pageToken'] = $token;
}

$out = self::api_get($this->endPoint['search'], $params);

foreach($out->items as $o) {
$ids[] = $o->id->videoId;
}

if (isset($out->prevPageToken)) {
$info['page_info']['prevPage'] = $out->prevPageToken;
}
if (isset($out->nextPageToken)) {
$info['page_info']['nextPage'] = $out->nextPageToken;
}

$info['content'] = self::formatVideos($ids);

return $info;

}
public function chart($maxResults, $token = null) {



$params = array(

'chart' => 'mostPopular',

'type' => 'video',

'part' => 'id',

'order' => 'relevance',

'maxResults' => $maxResults

);



if (!is_null($token)) {

$params['pageToken'] = $token;

}



$out = self::api_get($this->endPoint['videos'], $params);



foreach($out->items as $o) {

$ids[] = $o->id->videoId;

}



if (isset($out->prevPageToken)) {

$info['page_info']['prevPage'] = $out->prevPageToken;

}

if (isset($out->nextPageToken)) {

$info['page_info']['nextPage'] = $out->nextPageToken;

}



$info['content'] = self::formatVideos($ids);



return $info;



}


public function videoByCat($catID, $maxResults, $token = null) {



$params = array(

'videoCategoryId' => $catID,

'type' => 'video',

'part' => 'id',

'order' => 'relevance',

'maxResults' => $maxResults

);



if (!is_null($token)) {

$params['pageToken'] = $token;

}



$out = self::api_get($this->endPoint['videos'], $params);



foreach($out->items as $o) {

$ids[] = $o->id->videoId;

}



if (isset($out->prevPageToken)) {

$info['page_info']['prevPage'] = $out->prevPageToken;

}

if (isset($out->nextPageToken)) {

$info['page_info']['nextPage'] = $out->nextPageToken;

}



$info['content'] = self::formatVideos($ids);



return $info;



}


public function search($q, $maxResults, $token = null) {

Expand Down

0 comments on commit 40b2dde

Please sign in to comment.