下記コードは、Jsonの取得のところまで。
<?php require_once('vendor/autoload.php'); $client_id = ''; $service_account_name = ''; $key_file_location = ''; $client = new Google_Client(); $client->setApplicationName('Yutube Test'); $key = file_get_contents($key_file_location); $cred = new Google_Auth_AssertionCredentials( $service_account_name, array('https://www.googleapis.com/auth/youtube'), $key ); $client->setAssertionCredentials($cred); $youtube = new Google_Service_YouTube($client); $array = array('viewCount','rating','date'); $query = 'X Japan'; $searchResponse = $youtube->search->listSearch('id,snippet',array( 'q' => $query, 'maxResults'=> 10, 'order' => $array[0] ));
こちらがviewです。検索やソート順など、改良の余地が大いにありますね。