Instagram real-time tag update - callback called twice?

I use instagram real time updates for a tag to get notified when someone loses the environment with a specific tag. The subscription works fine, and I can directly verify the subscription using https://api.instagram.com/v1/subscriptions?client_secret= {cs} & client_id = {cid}

Inside the 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 } 

}

But this callback is executed twice by instagram. For example, if I subscribe to a โ€œwinterโ€ tag, and if someone publishes the media and marks it using this tag, instagram will send a notification twice to the reverse file i specified during the subscription (both calls are completed within a few seconds). Why send a callback request twice? Has anyone had a similar problem?

+8
php instagram-api
source share
1 answer

After debugging and investigating, I found that the call is sent from instagram twice if the reverse file is not running fast enough.

Based on the documentation :

In addition, you must recognize POST within a 2-second timeout - if you need to process the received information more, you can therefore do it in an asynchronous task.

They will send a second request in case they do not receive a response to the first request within 2 seconds.

In the end, I had an empty callback.php file with only โ€œsleepingโ€ inside it, and it was called twice every time.

+7
source share

All Articles