We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, I've created a new function to retrieve all videos with automatic token!
Check the code below:
private $next = array(); private $playItemsArray = array(); public function getAllPlaylistItemsByPlaylistId($playlistId,$maxResults=50,$pageToken=""){ $API_URL = $this->getApi('playlistItems.list'); $params = array( 'playlistId' => $playlistId, 'part' => 'id, snippet, contentDetails, status', 'maxResults' => $maxResults, 'pageToken' => $pageToken ); $apiData = $this->api_get($API_URL, $params); return $this->decodePlayList($apiData,$playlistId); } public function decodePlayList(&$apiData,$id){ $resObj = json_decode($apiData); if(isset($resObj->error)){ $msg = "Error ".$resObj->error->code." ".$resObj->error->message; if(isset($resObj->error->errors[0])){ $msg .= " : " . $resObj->error->errors[0]->reason; } throw new \Exception($msg); }else{ $itemsArray = $resObj->items; if(!is_array($itemsArray) || count($itemsArray) == 0){ return FALSE; }else{ if (isset($resObj->nextPageToken)) { array_unshift ($this->next, $resObj->nextPageToken); $this->playItemsArray = array_merge($this->playItemsArray,$itemsArray); self::getAllPlaylistItemsByPlaylistId($id,50,$this->next[0]); } else { $this->playItemsArray = array_merge($this->playItemsArray,$itemsArray); } return $this->playItemsArray; } } }
I've checked and this function just consume 60 Google Developer points (with 300 videos) and take around 35 seconds to run !
If you guys have another better way to do it tell or post it here!
This is very powerful when you want to get all videos 🎯
Best Regards,
Peterson Tubini
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
I've created a new function to retrieve all videos with automatic token!
Check the code below:
I've checked and this function just consume 60 Google Developer points (with 300 videos) and take around 35 seconds to run !
If you guys have another better way to do it tell or post it here!
This is very powerful when you want to get all videos 🎯
Best Regards,
Peterson Tubini
The text was updated successfully, but these errors were encountered: