drpfu51608120170 2015-05-11 18:55
浏览 46

无法在php session_start()脚本中获取$ _GET变量

I have a file called fbconfig.php

If I append a variable to a url http://localhost/fbconfig.php?amount=700 I cannot retrieve the variable in the script.

  <?php 
session_start();
$amount = $_GET['amount'];
echo $amount; // NOTHING HAPPENS

// added in v4.0.0
require_once 'autoload.php';
//require 'functions.php';
require 'dbconfig.php';
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
// Other Variables

// init app with app id and secret
FacebookSession::setDefaultApplication( '123123123','12312312' );
// login helper with redirect_uri
    $helper = new FacebookRedirectLoginHelper('http://localhost/fbconfig.php' );
try {
  $session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
  // When Facebook returns an error
} catch( Exception $ex ) {
  // When validation fails or other local issues
}
// see if we have a session
if ( isset( $session ) ) {
  // graph api request for user data
  $request = new FacebookRequest( $session, 'GET', '/me' );
  $response = $request->execute();
  // get response
  $graphObject = $response->getGraphObject();
        $fbid = $graphObject->getProperty('id');              // To Get Facebook ID
        $fbfullname = $graphObject->getProperty('name'); // To Get Facebook full name
        $fbfirstname = $graphObject->getProperty('first_name'); // To Get Facebook full name
        $fbsecondname = $graphObject->getProperty('last_name'); // To Get Facebook full name
        $femail = $graphObject->getProperty('email');    // To Get Facebook email ID
    /* ---- Session Variables -----*/
        $_SESSION['FBID'] = $fbid;           
        $_SESSION['FULLNAME'] = $fbfullname;
        $_SESSION['EMAIL'] = $femail;
        $_SESSION['FBFIRSTNAME'] =  $fbfirstname;
        $_SESSION['FBSECONDNAME'] =  $fbsecondname;


//checkuser($fbid,$fbfullname,$femail,$amount,$days);

    /* ---- header location after session ----*/
  //header("Location: apply.php?amount=".$a."&days=".$b."");
} else {
  $loginUrl = $helper->getLoginUrl();
 //header("Location: ".$loginUrl);
}

echo $amount; // NOTHING HAPPENS
?>

So any ideas why I can't get the variable? I've tried so many different methods

thanks

  • 写回答

1条回答 默认 最新

  • doucheng4660 2015-05-12 15:18
    关注

    It's a cron job?

    * * * * * /path_to_script/fbconfig.php amount=700
    

    Passing $_GET parameters to cron job

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看