Instagram实时更新标签-回调调用过两次? [英] Instagram Real time updates tag - callback called twice?

查看:113
本文介绍了Instagram实时更新标签-回调调用过两次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用instagram实时更新标签,以在有人使用特定标签标记媒体时获得通知.订阅工作正常,并且无法使用来直接检查订阅 https://api.instagram.com/v1/subscriptions?client_secret= {cs }& client_id = {cid}

I am using instagram real time updates for tag, to get notification when someone tag media with specific tag. Subscription works fine, and im able to check subscription directly using https://api.instagram.com/v1/subscriptions?client_secret={cs}&client_id={cid}

在回调中,我有类似的东西

Within callback i have something like

if (isset ($_GET['hub_challenge'])){
    echo $_GET['hub_challenge'];
}
else{
    $my_string = file_get_contents('php://input');
    $sub_update = json_decode($my_string);
    //do the rest of the things with data we fetched
}

}

但是,此回调从instagram端执行了两次.因此,例如,如果我订阅"winter"标签,并且如果有人发布媒体并使用该标签对其进行标签,则instagram将向订阅期间指定的回调文件i发送两次通知(两次调用均在几秒钟内执行).为什么instagram向回调发送两次请求?有人遇到过类似的问题吗?

But, this callback is executed twice from instagram side. So for example, if i subscribe to "winter" tag, and if someone publish media and tag it using that tag, instagram will send notification twice to callback file i specified during subscription (both calls are executed within few secs). Why instagram sending request twice to the callback? Anyone had similar issue?

推荐答案

在调试和调查之后,我发现如果回调文件执行得不够快,则会从instagram发送两次呼叫.

After debugging and investigation i found that call is sent from instagram twice if callback file is not executed fast enough.

基于文档:

此外,您应该在2秒钟的超时时间内确认POST-如果 您需要对接收到的信息进行更多处理,就可以 所以在异步任务中.

Also, you should acknowledge the POST within a 2 second timeout--if you need to do more processing of the received information, you can do so in an asynchronous task.

如果他们在2秒内未收到对第一个请求的响应,他们将发送第二个请求.

They will send second request in case they dont receive response on first request within 2 secs.

最后,我有一个空白的callback.php文件,里面只有"sleep",并且每次被调用两次.

At the end, i had blank callback.php file with only "sleep" inside it and its called twice each time.

这篇关于Instagram实时更新标签-回调调用过两次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆