gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 12:17:18 25 4
gpt4 key购买 nike

我正在为标签使用 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/

25 4 0