您可以使用YouTube开发人员API。获取以下最新视频的示例:
$data = wp_remote_get(\'http://gdata.youtube.com/feeds/api/users/<USERNAME>/uploads/?start-index=1&max-results=40\');
$response = new SimpleXMLElement($data[\'body\']);
foreach ($response->entry as $entry):
$vid_id = \'\';
if ( preg_match(\'#videos/([^/]+)$#\', $entry->id, $matches) ) {
$vid_id = $matches[1];
}
if ( $vid_id ):
?>
<a href="http://youtube.com/watch?v=<?php echo $vid_id; ?>">
<img src="http://i.ytimg.com/vi/<?php echo $vid_id; ?>/1.jpg" width="220" height="130" />
<span class="video-title"><?php echo esc_html($entry->title); ?></span>
<span class="video-description"><?php echo esc_html($entry->content); ?></span>
</a>
<?php
endif;
endforeach;