Skip to content

Commit

Permalink
fix: part param doesn't accept space anymore (#152)
Browse files Browse the repository at this point in the history
All the lib queries stopped to work for me today, debbuging I see that without the space in `part` parameter, everything works normally again.
  • Loading branch information
ibrunotome authored Jul 8, 2020
1 parent be04bbe commit 6f1fc13
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/Youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function getCategories($regionCode = 'US', $part = ['snippet'])
$API_URL = $this->getApi('categories.list');
$params = [
'key' => $this->youtube_key,
'part' => implode(', ', $part),
'part' => implode(',', $part),
'regionCode' => $regionCode
];

Expand Down Expand Up @@ -133,7 +133,7 @@ public function getCommentThreads($channelId = null, $id = null, $videoId = null
'id' => $id,
'videoId' => $videoId,
'maxResults' => $maxResults,
'part' => implode(', ', $part),
'part' => implode(',', $part),
'order' => $order,
]);

Expand Down Expand Up @@ -161,7 +161,7 @@ public function getVideoInfo($vId, $part = ['id', 'snippet', 'contentDetails', '
$params = [
'id' => is_array($vId) ? implode(',', $vId) : $vId,
'key' => $this->youtube_key,
'part' => implode(', ', $part),
'part' => implode(',', $part),
];

$apiData = $this->api_get($API_URL, $params);
Expand All @@ -172,7 +172,7 @@ public function getVideoInfo($vId, $part = ['id', 'snippet', 'contentDetails', '

return $this->decodeSingle($apiData);
}

/**
* Gets localized video info by language (f.ex. de) by adding this parameter after video id
* Youtube::getLocalizedVideoInfo($video->url, 'de')
Expand All @@ -191,7 +191,7 @@ public function getLocalizedVideoInfo($vId, $language, $part = ['id', 'snippet',
'id' => is_array($vId) ? implode(',', $vId) : $vId,
'key' => $this->youtube_key,
'hl' => $language,
'part' => implode(', ', $part),
'part' => implode(',', $part),
];

$apiData = $this->api_get($API_URL, $params);
Expand All @@ -216,7 +216,7 @@ public function getPopularVideos($regionCode, $maxResults = 10, $part = ['id', '
$API_URL = $this->getApi('videos.list');
$params = [
'chart' => 'mostPopular',
'part' => implode(', ', $part),
'part' => implode(',', $part),
'regionCode' => $regionCode,
'maxResults' => $maxResults,
];
Expand All @@ -239,7 +239,7 @@ public function search($q, $maxResults = 10, $part = ['id', 'snippet'])
{
$params = [
'q' => $q,
'part' => implode(', ', $part),
'part' => implode(',', $part),
'maxResults' => $maxResults,
];

Expand All @@ -260,7 +260,7 @@ public function searchVideos($q, $maxResults = 10, $order = null, $part = ['id']
$params = [
'q' => $q,
'type' => 'video',
'part' => implode(', ', $part),
'part' => implode(',', $part),
'maxResults' => $maxResults,
];
if (!empty($order)) {
Expand All @@ -287,7 +287,7 @@ public function searchChannelVideos($q, $channelId, $maxResults = 10, $order = n
'q' => $q,
'type' => 'video',
'channelId' => $channelId,
'part' => implode(', ', $part),
'part' => implode(',', $part),
'maxResults' => $maxResults,
];
if (!empty($order)) {
Expand All @@ -312,7 +312,7 @@ public function listChannelVideos($channelId, $maxResults = 10, $order = null, $
$params = [
'type' => 'video',
'channelId' => $channelId,
'part' => implode(', ', $part),
'part' => implode(',', $part),
'maxResults' => $maxResults,
];
if (!empty($order)) {
Expand Down Expand Up @@ -381,11 +381,11 @@ public function getChannelByName($username, $optionalParams = [], $part = ['id',
$API_URL = $this->getApi('channels.list');
$params = [
'forUsername' => $username,
'part' => implode(', ', $part),
'part' => implode(',', $part),
];

$params = array_merge($params, $optionalParams);

$apiData = $this->api_get($API_URL, $params);

return $this->decodeSingle($apiData);
Expand All @@ -403,11 +403,11 @@ public function getChannelById($id, $optionalParams = [], $part = ['id', 'snippe
$API_URL = $this->getApi('channels.list');
$params = [
'id' => is_array($id) ? implode(',', $id) : $id,
'part' => implode(', ', $part),
'part' => implode(',', $part),
];

$params = array_merge($params, $optionalParams);

$apiData = $this->api_get($API_URL, $params);

if (is_array($id)) {
Expand All @@ -429,10 +429,10 @@ public function getPlaylistsByChannelId($channelId, $optionalParams = [], $part
$API_URL = $this->getApi('playlists.list');
$params = [
'channelId' => $channelId,
'part' => implode(', ', $part)
'part' => implode(',', $part)
];
$params = array_merge($params, $optionalParams);

$params = array_merge($params, $optionalParams);

$apiData = $this->api_get($API_URL, $params);

Expand All @@ -455,7 +455,7 @@ public function getPlaylistById($id, $part = ['id', 'snippet', 'status'])
$API_URL = $this->getApi('playlists.list');
$params = [
'id' => is_array($id)? implode(',', $id) : $id,
'part' => implode(', ', $part),
'part' => implode(',', $part),
];
$apiData = $this->api_get($API_URL, $params);

Expand All @@ -479,7 +479,7 @@ public function getPlaylistItemsByPlaylistId($playlistId, $pageToken = '', $maxR
$API_URL = $this->getApi('playlistItems.list');
$params = [
'playlistId' => $playlistId,
'part' => implode(', ', $part),
'part' => implode(',', $part),
'maxResults' => $maxResults,
];

Expand Down Expand Up @@ -512,7 +512,7 @@ public function getActivitiesByChannelId($channelId, $part = ['id', 'snippet', '
$API_URL = $this->getApi('activities');
$params = [
'channelId' => $channelId,
'part' => implode(', ', $part),
'part' => implode(',', $part),
'maxResults' => $maxResults,
'pageToken' => $pageToken,
];
Expand Down Expand Up @@ -544,7 +544,7 @@ public function getRelatedVideos($videoId, $maxResults = 5, $part = ['id', 'snip
$params = [
'type' => 'video',
'relatedToVideoId' => $videoId,
'part' => implode(', ', $part),
'part' => implode(',', $part),
'maxResults' => $maxResults,
];
$apiData = $this->api_get($API_URL, $params);
Expand Down Expand Up @@ -736,11 +736,11 @@ public function api_get($url, $params)

//boilerplates for CURL
$tuCurl = curl_init();

if (isset($_SERVER['HTTP_HOST']) && $this->config['use-http-host']) {
curl_setopt($tuCurl, CURLOPT_HEADER, array('Referer' => $_SERVER['HTTP_HOST']));
}

curl_setopt($tuCurl, CURLOPT_URL, $url . (strpos($url, '?') === false ? '?' : '') . http_build_query($params));
if (strpos($url, 'https') === false) {
curl_setopt($tuCurl, CURLOPT_PORT, 80);
Expand Down

0 comments on commit 6f1fc13

Please sign in to comment.