这是我订阅/取消订阅实时 Instagram API 的代码。取消订阅有效,但订阅无效。我不太擅长 cUrl,我只是使用了http://thegregthompson.com/instagram-real-time-api-php/中的这部分代码并进行了一些额外的定制。
<?php
$url = "https://api.instagram.com/v1/subscriptions/";
$ch = curl_init();
if (isset($_GET['unsubscribe']))
{
echo "unsubscribe";
$url .= "?client_id=" . $config['instagram']['client_id'] . "&client_secret=" .
$config['instagram']['client_secret'] . "&id=" . $_GET['tag'];
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
}
else
{
$attachment = array(
'client_id' => $config['instagram']['client_id'],
'client_secret' => $config['instagram']['client_secret'],
'object' => 'tag',
'object_id' => $_GET['tag'],
'aspect' => 'media',
'verify_token' => $config['instagram']['verify_token'],
'callback_url'=> 'http://' . $_SERVER['HTTP_HOST'] . '/callback/endpoint.php'
);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_POST, true);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result = curl_exec($ch);
curl_close ($ch);
print_r($result);
?>
$config 已正确包含。
我花了很多时间试图修复它,但没有办法。你能帮我完成订阅吗?
问我是否需要更多详细信息。
非常感谢