2017-06-04 15 views
0

youtube apiでphpのタイトルで注文する方法は? search.listのドキュメントでは、orderはオプションのパラメータであると言います。タイトルや日付で印刷するものはどのように注文するのですか? 試し{タイトル順の検索タイトルapi

// Call the search.list method to retrieve results matching the specified 
// query term. 
$searchResponse = $youtube->search->listSearch('id,snippet', array(
    'q' => $_GET['q'], 
    'maxResults' => $_GET['maxResults'], 
)); 

$videos = ''; 
$channels = ''; 
$playlists = ''; 
// Add each result to the appropriate list, and then display the lists of 
// matching videos, channels, and playlists. 
foreach ($searchResponse['items'] as $searchResult) { 
    switch ($searchResult['id']['snippet']) { 
    case 'youtube#video': 
     $videos .= sprintf('<li>title=%s link = http://youtube.com/watch?v=%s/ channelid = %s</li><br> ', 
      $searchResult['snippet']['title'], $searchResult['id']['videoId'], $searchResult['snippet']['channelTitle']); 
     break; 

答えて

1

あなたはタイトル、日付、評価、妥当性、VIDEOCOUNT、および再生回数でソートするためのパラメータを使用することができます。オーダーのドキュメントを見てみましょう:https://developers.google.com/youtube/v3/docs/search/list

このコードの種類をタイトル

// Call the search.list method to retrieve results matching the specified 
// query term. 
$searchResponse = $youtube->search->listSearch('id,snippet', array(
    'q' => $_GET['q'], 
    'maxResults' => $_GET['maxResults'], 
    'order' => 'title' 
)); 

このコードの種類によって日付

// Call the search.list method to retrieve results matching the specified 
// query term. 
$searchResponse = $youtube->search->listSearch('id,snippet', array(
    'q' => $_GET['q'], 
    'maxResults' => $_GET['maxResults'], 
    'order' => 'date' 
)); 
+0

おかげで!私は仕事にそれを得た –

+0

恐ろしい!私はそれを聞いてうれしい。 –

+0

私が 'order' => 'viewCount'を実行すると、何も返されません。 –

関連する問題