【发布时间】:2017-06-04 13:52:16
【问题描述】:
如何在 youtube api 的 php 中按标题排序?在 search.list 的文档中,它说 order 是一个可选参数。如何按标题或日期订购我打印的内容? 试试 {
// 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;
【问题讨论】:
标签: php youtube youtube-api youtube-data-api