Instagram API - Retrieve Only Videos

倖福魔咒の 提交于 2019-12-10 21:32:11

问题


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)

Thanks in advance!


回答1:


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;
    }
}


来源:https://stackoverflow.com/questions/29634194/instagram-api-retrieve-only-videos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!