簡體   English   中英

php session_start()腳本中無法獲取$ _GET變量

[英]can't get $_GET variable in php session_start() script

我有一個名為fbconfig.php的文件

如果我將變量附加到URL http://localhost/fbconfig.php?amount = 700 ,則無法在腳本中檢索該變量。

  <?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
?>

那么有什么主意為什么我不能得到這個變量? 我嘗試了很多不同的方法

謝謝

這是一項計划工作?

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

將$ _GET參數傳遞給cron作業

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM