我使用此代碼在Instagram API上登錄,但在某些服務器上,此代碼正確運行,但在其他服務器上我無法獲取instagram數據。誰知道爲什麼?如何從「某些」服務器上的instagram獲取數據
<?php
require 'instagram.class.php';
require 'instagram.config.php';
// Receive OAuth code parameter
$code = $_GET['code'];
// Check whether the user has granted access
if (true === isset($code)) {
// Receive OAuth token object
$data = $instagram->getOAuthToken($code);
if(empty($data->user->username))
{
echo "1";
}
else
{
session_start();
$_SESSION['userdetails']=$data;
echo $user=$data->user->username;
echo $fullname=$data->user->full_name;
echo $bio=$data->user->bio;
echo $website=$data->user->website;
echo $id=$data->user->id;
echo $token=$data->access_token;
}
}
else
{
// Check whether an error occurred
if (true === isset($_GET['error']))
{
echo 'An error occurred: '.$_GET['error_description'];
}
}
?>
您可能需要啓用粘性會話[負載均衡],我使用memcache作爲我的session.save_handler和php共享相同的會話 –