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条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效