Skip to content

Youtube api 'unknownPart' status #1777

@foremtehan

Description

@foremtehan

I want to search video by string/title but it throws a exception:

class Youtube
{

    private Google_Service_YouTube $service;

    public function __construct()
    {

        $client = new \Google_Client();


        $client->setDeveloperKey(self::API_KEY);

        $this->service = new \Google_Service_YouTube($client);
    }

    public function search($query)
    {
        $items = [];

        $results = $this->service->search->listSearch($query);

        foreach ($results->getItems() as $k => $item) {
            $items[] = $item;
        }
        return $items;
    }
}
$youtube= new Youtube;

$youtube->search('video title');
Google_Service_Exception : {
 "error": {
  "errors": [
   {
    "domain": "youtube.part",
    "reason": "unknownPart",
    "message": "video title",
    "locationType": "parameter",
    "location": "part"
   }
  ],
  "code": 400,
  "message": "video title"
 }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions