Skip to content

Commit 6f1fc13

Browse files
authored
fix: part param doesn't accept space anymore (#152)
All the lib queries stopped to work for me today, debbuging I see that without the space in `part` parameter, everything works normally again.
1 parent be04bbe commit 6f1fc13

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/Youtube.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function getCategories($regionCode = 'US', $part = ['snippet'])
9191
$API_URL = $this->getApi('categories.list');
9292
$params = [
9393
'key' => $this->youtube_key,
94-
'part' => implode(', ', $part),
94+
'part' => implode(',', $part),
9595
'regionCode' => $regionCode
9696
];
9797

@@ -133,7 +133,7 @@ public function getCommentThreads($channelId = null, $id = null, $videoId = null
133133
'id' => $id,
134134
'videoId' => $videoId,
135135
'maxResults' => $maxResults,
136-
'part' => implode(', ', $part),
136+
'part' => implode(',', $part),
137137
'order' => $order,
138138
]);
139139

@@ -161,7 +161,7 @@ public function getVideoInfo($vId, $part = ['id', 'snippet', 'contentDetails', '
161161
$params = [
162162
'id' => is_array($vId) ? implode(',', $vId) : $vId,
163163
'key' => $this->youtube_key,
164-
'part' => implode(', ', $part),
164+
'part' => implode(',', $part),
165165
];
166166

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

173173
return $this->decodeSingle($apiData);
174174
}
175-
175+
176176
/**
177177
* Gets localized video info by language (f.ex. de) by adding this parameter after video id
178178
* Youtube::getLocalizedVideoInfo($video->url, 'de')
@@ -191,7 +191,7 @@ public function getLocalizedVideoInfo($vId, $language, $part = ['id', 'snippet',
191191
'id' => is_array($vId) ? implode(',', $vId) : $vId,
192192
'key' => $this->youtube_key,
193193
'hl' => $language,
194-
'part' => implode(', ', $part),
194+
'part' => implode(',', $part),
195195
];
196196

197197
$apiData = $this->api_get($API_URL, $params);
@@ -216,7 +216,7 @@ public function getPopularVideos($regionCode, $maxResults = 10, $part = ['id', '
216216
$API_URL = $this->getApi('videos.list');
217217
$params = [
218218
'chart' => 'mostPopular',
219-
'part' => implode(', ', $part),
219+
'part' => implode(',', $part),
220220
'regionCode' => $regionCode,
221221
'maxResults' => $maxResults,
222222
];
@@ -239,7 +239,7 @@ public function search($q, $maxResults = 10, $part = ['id', 'snippet'])
239239
{
240240
$params = [
241241
'q' => $q,
242-
'part' => implode(', ', $part),
242+
'part' => implode(',', $part),
243243
'maxResults' => $maxResults,
244244
];
245245

@@ -260,7 +260,7 @@ public function searchVideos($q, $maxResults = 10, $order = null, $part = ['id']
260260
$params = [
261261
'q' => $q,
262262
'type' => 'video',
263-
'part' => implode(', ', $part),
263+
'part' => implode(',', $part),
264264
'maxResults' => $maxResults,
265265
];
266266
if (!empty($order)) {
@@ -287,7 +287,7 @@ public function searchChannelVideos($q, $channelId, $maxResults = 10, $order = n
287287
'q' => $q,
288288
'type' => 'video',
289289
'channelId' => $channelId,
290-
'part' => implode(', ', $part),
290+
'part' => implode(',', $part),
291291
'maxResults' => $maxResults,
292292
];
293293
if (!empty($order)) {
@@ -312,7 +312,7 @@ public function listChannelVideos($channelId, $maxResults = 10, $order = null, $
312312
$params = [
313313
'type' => 'video',
314314
'channelId' => $channelId,
315-
'part' => implode(', ', $part),
315+
'part' => implode(',', $part),
316316
'maxResults' => $maxResults,
317317
];
318318
if (!empty($order)) {
@@ -381,11 +381,11 @@ public function getChannelByName($username, $optionalParams = [], $part = ['id',
381381
$API_URL = $this->getApi('channels.list');
382382
$params = [
383383
'forUsername' => $username,
384-
'part' => implode(', ', $part),
384+
'part' => implode(',', $part),
385385
];
386-
386+
387387
$params = array_merge($params, $optionalParams);
388-
388+
389389
$apiData = $this->api_get($API_URL, $params);
390390

391391
return $this->decodeSingle($apiData);
@@ -403,11 +403,11 @@ public function getChannelById($id, $optionalParams = [], $part = ['id', 'snippe
403403
$API_URL = $this->getApi('channels.list');
404404
$params = [
405405
'id' => is_array($id) ? implode(',', $id) : $id,
406-
'part' => implode(', ', $part),
406+
'part' => implode(',', $part),
407407
];
408-
408+
409409
$params = array_merge($params, $optionalParams);
410-
410+
411411
$apiData = $this->api_get($API_URL, $params);
412412

413413
if (is_array($id)) {
@@ -429,10 +429,10 @@ public function getPlaylistsByChannelId($channelId, $optionalParams = [], $part
429429
$API_URL = $this->getApi('playlists.list');
430430
$params = [
431431
'channelId' => $channelId,
432-
'part' => implode(', ', $part)
432+
'part' => implode(',', $part)
433433
];
434-
435-
$params = array_merge($params, $optionalParams);
434+
435+
$params = array_merge($params, $optionalParams);
436436

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

@@ -455,7 +455,7 @@ public function getPlaylistById($id, $part = ['id', 'snippet', 'status'])
455455
$API_URL = $this->getApi('playlists.list');
456456
$params = [
457457
'id' => is_array($id)? implode(',', $id) : $id,
458-
'part' => implode(', ', $part),
458+
'part' => implode(',', $part),
459459
];
460460
$apiData = $this->api_get($API_URL, $params);
461461

@@ -479,7 +479,7 @@ public function getPlaylistItemsByPlaylistId($playlistId, $pageToken = '', $maxR
479479
$API_URL = $this->getApi('playlistItems.list');
480480
$params = [
481481
'playlistId' => $playlistId,
482-
'part' => implode(', ', $part),
482+
'part' => implode(',', $part),
483483
'maxResults' => $maxResults,
484484
];
485485

@@ -512,7 +512,7 @@ public function getActivitiesByChannelId($channelId, $part = ['id', 'snippet', '
512512
$API_URL = $this->getApi('activities');
513513
$params = [
514514
'channelId' => $channelId,
515-
'part' => implode(', ', $part),
515+
'part' => implode(',', $part),
516516
'maxResults' => $maxResults,
517517
'pageToken' => $pageToken,
518518
];
@@ -544,7 +544,7 @@ public function getRelatedVideos($videoId, $maxResults = 5, $part = ['id', 'snip
544544
$params = [
545545
'type' => 'video',
546546
'relatedToVideoId' => $videoId,
547-
'part' => implode(', ', $part),
547+
'part' => implode(',', $part),
548548
'maxResults' => $maxResults,
549549
];
550550
$apiData = $this->api_get($API_URL, $params);
@@ -736,11 +736,11 @@ public function api_get($url, $params)
736736

737737
//boilerplates for CURL
738738
$tuCurl = curl_init();
739-
739+
740740
if (isset($_SERVER['HTTP_HOST']) && $this->config['use-http-host']) {
741741
curl_setopt($tuCurl, CURLOPT_HEADER, array('Referer' => $_SERVER['HTTP_HOST']));
742742
}
743-
743+
744744
curl_setopt($tuCurl, CURLOPT_URL, $url . (strpos($url, '?') === false ? '?' : '') . http_build_query($params));
745745
if (strpos($url, 'https') === false) {
746746
curl_setopt($tuCurl, CURLOPT_PORT, 80);

0 commit comments

Comments
 (0)