问题描述
我只需要检索带有特定主题标签的视频.我了解没有任何方法只能检索视频,但是如何解析返回的JSON对象并仅使用视频呢?我一直在检查数组,但没有看到可以可靠地用于确定结果是视频还是照片的任何字段(例如:['type'] =>'image'确实很有帮助) (如果存在).
I need to retrieve ONLY videos tagged with a certain hashtag. I understand there isn't any way to retrieve only videos, but how could I parse through the JSON object I get back and only use the videos? I've been examining the array and I don't see any field that I could reliably use to determine if the result was a video or photo (ie, something like: ['type'] => 'image' would be really helpful, if it existed).
说句公道话,这是一个巨大的数组,我可能会遗漏一些显而易见的东西.
To be fair, this is a huge array, and I could be missing something obvious.
所以:有什么方法可以解析所有结果并仅使用视频? (然后将这些结果放入一个新数组中以供实际使用)
So: is there any way to parse through all the results and only use the videos? (I'd then put those results in a new array to actually use)
提前谢谢!
推荐答案
显然我很想念它!不仅有一种方法可以做到,而且这正是我所问的假设方法.有一个名为['type']的字段,可以等于视频"或图像"(或其他).
Apparently I WAS missing it! Not only is there a way to do it, but it's exactly the hypothetical way I asked about. There's a field called ['type'] which can equal 'video' or 'image' (or others, possibly).
因此,对于希望与我做相同事情的任何人,您可能想要编写类似以下内容的东西:
So, for anyone looking to do the same thing as me, you might want to write something like:
foreach ($obj->data as $post) {
// check media type and skip this result if
$media_type = $post->type;
if($media_type != 'video'){
continue;
}
}
这篇关于Instagram API-仅检索视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!