duanjue2560 2017-01-26 10:37
浏览 61
已采纳

在POST请求php中无法获取关闭url的参数

I Have a url here which I am using to send a post request to my server and I want to catch the EventType, RessourceId, and Date, and put their values in a array if possible. I am trying so many methods but for some reason I cannot get those information.

Here is the url

//POST
  https://localhost/hello/index.php/kyc_succeeded_hook?EventType=SUCCEEDED&RessourceId=1309853&Date=1397037093

I used first this method,

$data = file_get_contents("php://input");
        var_dump($data);
     //I get nothing back.

Then I tried this

$Query_String  = explode("&", explode("?", $_SERVER['REQUEST_URI'])[1] );
     var_dump($Query_String);

I get values back like this in postman if I echo it

<pre class='xdebug-var-dump' dir='ltr'>
    <b>array</b>
    <i>(size=3)</i>
  0
    <font color='#888a85'>=&gt;</font>
    <small>string</small>
    <font color='#cc0000'>'EventType=SUCCEEDED'</font>
    <i>(length=23)</i>
  1
    <font color='#888a85'>=&gt;</font>
    <small>string</small>
    <font color='#cc0000'>'RessourceId=1309853'</font>
    <i>(length=19)</i>
  2
    <font color='#888a85'>=&gt;</font>
    <small>string</small>
    <font color='#cc0000'>'Date=1397037093'</font>
    <i>(length=15)</i>
</pre>
<pre class='xdebug-var-dump' dir='ltr'>
    <small>string</small>
    <font color='#cc0000'>''</font>
    <i>(length=0)</i>
</pre>

I am not sure how to put those values in a array.

  • 写回答

2条回答 默认 最新

  • 普通网友 2017-01-26 10:40
    关注

    Query string variables that are appended to the url of the page are always seen as get variables, so you will need to use the $_GET array to find them.

    So, to get the EventType, you can do the following:

    $eventType = $_GET['EventType'];
    

    If you want all get and post variables in one array, you can use the $_REQUEST array.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 有人能看一下我宿舍管理系统的报修功能该怎么改啊?链表那里总是越界
  • ¥15 cs loadimage运行不了,easyx也下了,没有用
  • ¥15 r包runway详细安装教程
  • ¥15 Html中读取Json文件中数据并制作表格
  • ¥15 谁有RH342练习环境
  • ¥15 STM32F407 DMA中断问题
  • ¥15 uniapp连接阿里云无法发布消息和订阅
  • ¥25 麦当劳点餐系统代码纠错
  • ¥15 轮班监督委员会问题。
  • ¥20 关于变压器的具体案例分析