Instagram Real time updates tag - getting empty data, why?

后端 未结 2 498
滥情空心
滥情空心 2020-12-30 16:12

Heloo,

I am working on one project and I need real time updates from Instagram for certain tag.

This is my code for Create a Subscription

&l         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-30 17:01

    Instagram Realtime API subscription will only let you know when there has been an update to your subscribed object, not what the update is. Once you receive a notification, it is up to you to make a call to the API (in your case probably https://api.instagram.com/v1/tags/winter/media/recent ) and to see what the new content is.

    Depending on the volume of changes, you will probably want to batch these calls up at certain time intervals, but the below should be a good start. You'll also probably only want to retrieve items you haven't already retrieved.

     $v) // can be multiple updates per call
        {
            $recent_data = file_get_contents('https://api.instagram.com/v1/tags/'.$sub_update->object_id.'/media/recent?access_token='.$access_token);
            file_put_contents('activity.log', serialize($recent_data->data), FILE_APPEND | LOCK_EX);
        }
    
    }
    ?>
    

提交回复
热议问题