我知道 *wp_remote_get* 是一个 WordPress 函数,我应该将它发布在 wordpress.stackexchange 中,但是,我几乎可以肯定我的问题更多地出在一般的 PHP 方面。
问题:我需要检索在相册中找到的所有 Vimeo 视频,但我只得到 20 个。
方法:
$vmg_feed_url = 'http://vimeo.com/api/v2/';
$vmg_user = '2212323';
if($vmg_type == 'user'){ /** just an input variable checking whether the function should search for user or for album. in our case, it searches for album **/
$vmg_type_url = '';
} else {
$vmg_type_url = $vmg_type . '/';
}
$vmg_videos_url = $vmg_feed_url . $vmg_type_url . $vmg_user . '/videos.xml';
$videos_result = wp_remote_get($vmg_videos_url);
$vmg_videos = simplexml_load_string($videos_result['body']);
生成的 XML 是 http://vimeo.com/api/v2/album/2212323/videos.xml - 如您所见,我只检索了 20 个视频。
问题:我错过了什么吗?是否有函数/变量限制我可以检索的视频数量?我知道 wp_remote_get 给了我这些属性 ( from the WordPress Codex ):
$网址 (字符串)(必需)通用资源定位器 (URL)。 - 默认:无
$参数 (数组)(可选) - 默认:方法:GET,超时:5,重定向:5,httpversion:1.0,阻塞:true,headers:array(),body:null,cookies:array()
非常感谢任何帮助。如果我忘记了任何细节,请告诉我!
最佳答案
您的问题不在 wordpress 或 PHP 中。这是 API 限制:
http://developer.vimeo.com/apis/simple
Simple API responses include up to 20 items per page.
您可以通过在下一个请求中添加?page
参数来获取更多。
关于php - 来自 Vimeo 的 wp_remote_get 和/或 simplexml_load_string 是否有限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16759036/