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 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计