我使用此代码从Instagram API获取数据。代码在某些服务器上正确运行,但在其他服务器上,它不会从Instagram API接收数据。所有服务器都启用了“Curl”,谁知道发生了什么?
<?php
require 'instagram.class.php';
require 'config.php';
// Receive OAuth code parameter
$code = $_GET['code'];
// Check whether the user has granted access
if (true === isset($code)) {
// Receive OAuth token object
// Take a look at the API response
$data = $instagram->getOAuthToken($code);
if(empty($data->user->username)){
header('Location: index.php');
} else {
session_start();
$_SESSION['xxx']=$data;
$user=$data->user->username;
$ig_id=$data->user->id;
header('Location: profile.php');
}
} else {
// Check whether an error occurred
if (true === isset($_GET['error'])){
echo $_GET['error_description'];
}
}
?>