php - Instagram 实时更新标签 - 回调调用两次?

标签 php instagram-api

我正在为标签使用 instagram 实时更新,以便在有人使用特定标签标记媒体时收到通知。订阅工作正常,我可以直接使用检查订阅 https://api.instagram.com/v1/subscriptions?client_secret= {cs}&client_id={cid}

在回调中我有类似的东西

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 端执行了两次。因此,例如,如果我订阅“冬季”标签,并且如果有人发布媒体并使用该标签对其进行标记,instagram 将向我在订阅期间指定的回调文件发送两次通知(两次调用都在几秒钟内执行)。为什么 instagram 向回调发送两次请求?有人有类似的问题吗?

最佳答案

经过调试和调查,我发现如果回调文件执行得不够快,调用会从 instagram 发送两次。

基于documentation :

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 秒内没有收到对第一个请求的响应,他们将发送第二个请求。

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

关于php - Instagram 实时更新标签 - 回调调用两次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27380741/

相关文章:

php - 使用PHP进行产品搜索

javascript - Instagram API 不工作 : APINotFoundError

ios - 使用自定义 URL 方案在 Swift 中打开 Instagram 应用程序

php - 哪个数据库用于处理非常大的结果集?

javascript - 在表单上使用 jquery show() 和 hide()

javascript - 确定哪个链接引导您进入当前页面

php - 有没有办法知道哪个 PHP 文件在 Wordpress 中生成了一个页面?

java - 我们如何从 Instagram 获取访问 token

php - 代表用户从 Instagram 获取公共(public)内容

ios - Instagram API 和 IOS