SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot dawgbone's Avatar
    Join Date
    Dec 2003
    Location
    Brampton
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Posting to a URL and getting return info

    I need to post XML data to a URL, then retrieve another set of XML data back from them based on the original data I sent

    What's the best way to do that?

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    $sXML 
    '<xml><data /></xml>';
    $rCurl curl_init('http://www.url.co.uk/');
    $aCurlOptions = array(
        
    CURLOPT_RETURNTRANSFER    =>    true,
        
    CURLOPT_POST            =>    true,
        
    CURLOPT_POSTFIELDS        =>    $sXML,
        
    CURLOPT_HTTPHEADER        =>    array('Connection: close')
    );
    curl_setopt_array($aCurlOptions$rCurl);
    $sResponseXML curl_exec($rCurl);
    curl_close($rCurl);
    ?>
    $sResponseXML will hold the returned XML from the server.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Zealot dawgbone's Avatar
    Join Date
    Dec 2003
    Location
    Brampton
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    coolio.

    Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •