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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵