我的剧本:
function redtube_search($search, $page) {
$feedurl = 'http://api.redtube.com/?data=redtube.Videos.searchVideos&output=json&search='.$search.'&thumbsize=big&page='.$page;
$ch = curl_init();
$timeout = 15;
curl_setopt($ch,CURLOPT_URL,$feedurl);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
$content = json_decode($data,true);
return $content;
}
$videos = redtube_search('teen',1);
print_r($videos);
如何分配变量:title,thumbs,duration?
我想处理下载的内容。
答案 0 :(得分:0)
试试这个
foreach($videos['videos'] as $v){
// title, thumbs, duration?
$title = $v['video']['title'];
$thumb = $v['video']['thumb'];
$duration = $v['video']['duration'];
echo "Title: {$title}<br> Duration: {$duration}<br> Thumb: {$thumb}<br>";
}