PHP$get_uu;当数据从网站发布时为空,但不是手动url

PHP$get_uu;当数据从网站发布时为空,但不是手动url,php,http,nginx,get,Php,Http,Nginx,Get,我对这个脚本有一个奇怪的问题。我可以使用URL直接发布到它:“”。但是,如果试图从中发布相同的数据,假设变量中没有显示任何内容。我将nginx与PHP5一起使用 <?php $panel_url = 'http://example.com:23462/'; $username = $_GET['payer_email']; $invoice = $_GET['txn_id']; $trimmedinvoice = substr($invoice, -6); $password = $t

我对这个脚本有一个奇怪的问题。我可以使用URL直接发布到它:“”。但是,如果试图从中发布相同的数据,假设变量中没有显示任何内容。我将nginx与PHP5一起使用

<?php

$panel_url = 'http://example.com:23462/';

$username = $_GET['payer_email'];
$invoice = $_GET['txn_id'];
$trimmedinvoice = substr($invoice, -6);
$password = $trimmedinvoice;
$max_connections = 1;
$reseller = 0;
$bouquet_ids = array(
    1,
    2,
    3 );

$expirationdays = $_GET['custom'];
$expiration = "+$expirationdays day";
$expiredate = strtotime($expiration);

###############################################################################
$post_data = array( 'user_data' => array(
        'username' => $username,
        'password' => $password,
        'max_connections' => $max_connections,
        'is_restreamer' => $reseller,
        'exp_date' => $expiredate,
        'bouquet' => json_encode( $bouquet_ids ) ) );

$opts = array( 'http' => array(
        'method' => 'POST',
        'header' => 'Content-type: application/x-www-form-urlencoded',
        'content' => http_build_query( $post_data ) ) );

$context = stream_context_create( $opts );
$api_result = json_decode( file_get_contents( $panel_url . "api.php?action=user&sub=create", false, $context ) );

Echo "<b>Username:</b> <br>";
echo $username;

echo "<br></br>";
echo "<b>Password:<br></b>";
echo $password;

echo "<br></br>";
echo "<b>Expires (in unix time):<br></b>";
echo $expiredate;

?>
使用外部海报(如requestmaker)发布最后一块代码的输出:

内容类型:
text/html
数据:字符串(35)“付款人电子邮件=foo&txn\u id=9229fjfua822” 数组(0){ }
POST变量位于
$\u POST
中,而不是
$\u GET
(后者包含附加到URI的参数)

您可以使用包含POST和GET变量的
$\u REQUEST


更多信息,请参见。

问题中最后一段代码的输出是什么?使用外部网站的帖子:CONTENT\u TYPE:text/html
DATA:string(35)“payer\u email=foo&txn\u id=9229fjfua822”数组(0){}直接指向URL:CONTENT\u TYPE:DATA:string(0){}即使在最后一段代码中正确地发送了数据,它也不会显示在我的echo中,也不会正确地发送到API/面板。只有在直接向URL发送post时才正确。在代码中使用$\u GET时,在“调试”块代码中使用$\u post。我错过什么了吗?该死的。我的错!现在我明白了为什么文件中没有输出。正如Richard Smith在下面指出的,我应该使用$u请求来获取POST和get数据。谢谢你为我指出这一点!使用$\u请求更改了所有出现的$\u GET,脚本工作起来很有魅力!当你打赌被问题蒙蔽了双眼时,拥有两只以上的眼睛真是太好了。在通读了我所有的代码,没有发现任何问题之后,我确信问题出在服务器上。多谢各位!
print "CONTENT_TYPE: " . $_SERVER['CONTENT_TYPE'] . "<BR />";
$data = file_get_contents('php://input');
print "DATA: <pre>";
var_dump($data);
var_dump($_POST);
print "</pre>";
CONTENT_TYPE: 
DATA:
string(0) ""
array(0) {
}
CONTENT_TYPE:
text/html<BR />
DATA: <pre>string(35) "payer_email=foo&txn_id=9229fjfua822"
array(0) {
}