I'm having an issue where tag subscriptions we're creating are only lasting for about 30 callbacks
We're using PHP and cURL to talk to the Realtime API
Our callback.php merely logs the POST request received to a file so we can track how many times it's been called. After around 30 calls, it stops tracking, and when we query the API for a list of subscriptions, the subscription ID and TAG are no longer tracked... however, we receive no error in return, merely:
{"meta":{"code":200},"data":[]}
Our subscribe.php looks like this:
<?php
// client ids and secrets edited for posting
$client_id = 'XXXXXXXXXXXXXXXXXXX';
$client_secret = 'XXXXXXXXXXXXXXXXXXXXX';
$object = 'tag';
$object_id = $_GET['tag'];
$aspect = 'media';
$verify_token='';
$callback_url = 'http://vslve.com/app/callback.php';
$attachment = array(
'client_id' => $client_id,
'client_secret' => $client_secret,
'object' => $object,
'object_id' => $object_id,
'aspect' => $aspect,
'verify_token' => $verify_token,
'callback_url'=>$callback_url
);
$url = "https://api.instagram.com/v1/subscriptions/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result = curl_exec($ch);
curl_close ($ch);
$myString = $result;
$jsonArray = json_decode($myString);
foreach($jsonArray as $value){
$sub_id = $value->id;
}
$content = " ".$sub_id." ".$object_id."\r\n";
file_put_contents('subscribe.log', $content, FILE_APPEND);
print_r($result);
?>
And our callback.php
<?php
$challenge = $_GET['hub_challenge'];
if ($challenge) {
echo $challenge;
}else{
sleep(2);
$myString = file_get_contents('php://input');
$jsonArray = json_decode($myString);
foreach($jsonArray as $value){
$sub_id = $value->subscription_id;
$tag = $value->object_id;
$content = " ".$sub_id." ".$tag." ".$url."\r\n";
file_put_contents('activity.log', $content, FILE_APPEND);
}// end foreach
}// end if
?>
Are we going over our rate limit somehow? Any help as to why our subscriptions keep disappearing would be superb.