Bug订阅instagram API与cURL

这里是我的代码来订阅/取消订阅实时的Instagram API。 取消订阅的作品,但不是订阅。我不是很擅长cUrl,我只是使用http://thegregthompson.com/instagram-real-time-api-php/的这部分代码进行一些额外的定制。Bug订阅instagram API与cURL

<?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正确包含在内。

我花了很多时间来尝试修复它,但没办法。 你能帮我做订阅吗?

询问我是否需要更多详细信息。

非常感谢

回答:

好吧,我固定它:我想我们CURLOPT_POSTFIELDS之前应该设置CURLOPT_POST

正确

curl_setopt($ch, CURLOPT_POST, true); 

curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);

错误

curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment); 

curl_setopt($ch, CURLOPT_POST, true);

以上是 Bug订阅instagram API与cURL 的全部内容, 来源链接: utcz.com/qa/260750.html

回到顶部