Posting XML from PHP

There is a frequent need to post xml data to a url. Below is shown an example which lets you post xml data using CURL.


sdsd.


Download code

8 Responses

  1. Joel says:

    Excellent example. Clear, short, sweet and awesome handwriting font to boot. What font is that?

  2. Jess says:

    Wow excellent script but am getting error message “Bad Request (Invalid URL)” am using IP instead domain on URL

    can you help me what went wrong?

  3. Maven says:

    I’m getting the same error. Bad Request (Invalid URL)

  4. mike murray says:

    Hello. I’m very na├»ve to the idea of HTML, XML, and such. I was wondering if you could simply tell me how to take an XML feed or an HTML feed and automatically have it go to a post on my page? I have it set up already where e-mails automatically go to post, but I would really like to be able to take XML feeds from sports pages and have those automatically go to my posts. I hope I’m not sounding too stupid as I come from the day where I used to set the VCR for my dad. You can e-mail me back at the address I provided and I hope that you might build to provide me with an explanation. I can understand. Thank you very much for your time

  5. hli says:

    There is an error in your header options. After POST the uri is expected.
    So if you omit the headers apart from content-type everything works as expected.
    Or use this http://www.phpmind.com/blog/2009/08/how-to-post-xml-using-curl/ instead.

  6. Heya just wanted to give you a brief heads up and let you know
    a few of the images aren’t loading properly. I’m
    not sure why but I think its a linking issue.
    I’ve tried it in two different internet browsers and both show the same results.

  7. Erik Bortscht says:

    I used this method on a Apache Tomcat/7.0.16 webserver as target and always got the response 505 (unsupported http protocol version). Turned out the culprit was the extra space in
    “HTTP/1.0 \r\n”.

  1. September 19, 2012

    […] was using this link to figure it out: http://www.codediesel.com/php/posting-xml-from-php/ Sep 19, 2012 No Comments » Posted in PHP […]