Php reading xml in post request

20,366

Solution 1

I'm not really sure I understand what you are trying to do but try looking in to reading raw post data. Here is a blog post that talks about it a little bit.

http://www.codediesel.com/php/reading-raw-post-data-in-php/

Solution 2

If you want to send POST data from PHP, you could use cURL. You can't set $_POST or $_REQUEST at the sending side and expect them to be set at the receiving end as well.

Have a look at this question: Send XML over HTTPS/POST via cURL?

Share:
20,366
Kapil D
Author by

Kapil D

Updated on January 15, 2020

Comments

  • Kapil D
    Kapil D over 4 years

    So, I have perform two steps

    a) Create a some random xml file in one of the php file. b) Parse the same xml file in second file.

    Key points are that php file in a) will issue a post request to php file b) with only xml as its request.

    file b) will have to read the xml file using SImpleXml.

    I am trying to do something for this http://blog.superfeedr.com/API/pubsubhubbub/getting-started-with-pubsubhubbub/.

    I my server will be receiving notifications in form of xml from the the superfeeder. The notifications will be xml file in the request.

    I am doing step a) just to confirm that my part b) is correct.

    How to do this in PHP. I tried all the $_REQUEST, $GLOBALS variable. But, not sure whats the way!

  • Kapil D
    Kapil D over 14 years
    Now comes the second paart of parsing this xml! Also, how do I post the xml from a to b?
  • Chris Gutierrez
    Chris Gutierrez over 14 years
    You can parse the xml with the SimpleXML or DOMDocument library in PHP. To post xml, you can use cURL. Here is another post that talks about using curl to post data. stackoverflow.com/questions/871431/raw-post-using-curl-in-ph‌​p