我遇到的问题是,我们创建的代码订阅仅持续约30次回调
我们正在使用PHP和cURL与Realtime API进行交流
我们的callback.php只是将收到的POST请求记录到文件中,以便我们可以跟踪它被调用的次数。大约30次调用后,它会停止跟踪,当我们在API中查询订阅列表时,不会再跟踪订阅ID和TAG ...但是,我们收到的错误不仅仅是:
{"meta":{"code":200},"data":[]}
我们的subscribe.php如下所示:
<?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);
?>
我们的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
?>
我们是否以某种方式超过了我们的费率限制?任何关于我们的订阅为什么会一直消失的帮助都会很棒。