doulang1945 2014-04-11 15:50
浏览 113

如何从“某些”服务器上的instagram获取数据

I am using this code to login on Instagram API, but in some servers this code runs correctly, in other servers I can't get the instagram data. Who knows why?

<?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'];
}

}

?>
  • 写回答

1条回答 默认 最新

  • douzai9405 2014-04-11 16:11
    关注

    If you create session on a server, you cannot get it on other servers. You need to use sticky sessions. My suggesiton is installing memcache on one of your servers. You can see howto install here. After installation, let say your memcache server path is localhost:11211. You can configure your php to say that save your session in this memcache server instead of per server memory. You need following simple conf in your php.ini,

    session.save_handler = memcache 
    session.save_path = "tcp://localhost:11211"
    

    When you set any session, it will be created on this memcache server, and you can get it from any server. This settings mus be applied to all your servers. You need to give server name for session.save_path in all servers. Since, there is only one memcache server

    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?