我试图从Vimeo Api中检索字段的值,我试过了这里提到的所有可能的解决方案。有人能告诉我如何分别从缩略图和url对象中检索thumnail和url吗?从stdClass对象数组中获取数据
array(1) {
[0]=>
stdClass Object (
[allow_adds] => 1
[embed_privacy] => anywhere
[id] => 123456789
[is_hd] => 0
[is_transcoding] => 0
[license] => 0
[privacy] => anybody
[title] => Soap Opera
[description] =>
[upload_date] => 2014-02-20 03:03:50
[modified_date] => 2014-02-20 19:06:05
[number_of_plays] => 1
[number_of_likes] => 0
[number_of_comments] => 0
[width] => 600
[height] => 480
[duration] => 32
[owner] => stdClass Object (
[display_name] => blah
[id] => 12345678
[is_plus] => 0
[is_pro] => 1
[is_staff] => 0
[profileurl] => http://vimeo.com/st
[realname] => ST
[username] => ST
[videosurl] => http://vimeo.com/st/videos
[portraits] => stdClass Object (
[portrait] => Array (
[0] => stdClass Object (
[height] => 30
[width] => 30
[_content] => http://b.vimeocdn.com/x.jpg
)
[1] => stdClass Object (
[height] => 75
[width] => 75
[_content] => http://b.vimeocdn.com/x.jpg
)
[2] => stdClass Object (
[height] => 100
[width] => 100
[_content] => http://b.vimeocdn.com/x.jpg
)
[3] => stdClass Object (
[height] => 300
[width] => 300
[_content] => http://b.vimeocdn.com/x.jpg
)
)
)
)
[urls] => stdClass Object (
[url] => Array (
[0] => stdClass Object (
[type] => video
[_content] => http://vimeo.com/0000
)
)
)
[thumbnails] => stdClass Object (
[thumbnail] => Array (
[0] => stdClass Object (
[height] => 75
[width] => 100
[_content] => http://b.vimeocdn.com/x.jpg
)
)
)
)
我有一个数组$ VIDS具有各种VIDS的与获取的第二阵列$ vidInfo含有上述用于每个条目显示在阵列内循环另一呼叫沿着所述元信息。我可以检索标题等,就像我会正常访问一个对象。 但我不能再遍历上面的回应。
<?php
$vids = $videos->videos->video;
foreach ($vids as $vid){
$id = $vid->id;
$vidInfo = $vimeo->call('vimeo.videos.getInfo', array('video_id' => $id));
$vidUrl = $vidInfo->video;
echo $vid->title;
echo '<br />';
print_r($vidUrl->urls->url[0]->{'_content'});
//echo '<pre>' . print_r($vidUrl) . '</pre>';
}
?>
非常感谢
'$对象 - > urls->网址[0] - > _ content'是URL,和'$ object->缩略图 - >缩略图[0] - > _ content'就是缩略图...你到底想要去哪里? – Tularis
我一直试图整天,以及其他可能的方式来访问数组中的对象,但是当我循环它并尝试回显每个条目的url时,它将返回null。非常感谢你的回复。 :]它仍然不会在foreach循环中返回任何东西。 – SinSync
因此,向我们展示你已经尝试过(代码),我们会尽力帮助你。这个网站是关于学习做事情,而不仅仅是为了得到一个快速修复;) – Tularis