SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    nyc
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    POST and receive XML data (UPS Tools)

    Hi all
    I am trying to use UPS online tools in a PHP shopping Cart.
    To use the tools, I must POST XML data to the ups server, the UPS server then sends an XML response.
    I am hoping someone has done this before and could provide code examples, as UPS documentation only contains examples using Java and VB, not PHP. I do not understand anything about Java and VB.

    UPS doc reads:
    "The request HTTP message consists of a header section and a content section. The
    header section specifies the HTTP method (POST), the content type (application/x-www-formurlencoded), (...). The content of the HTTP message is the XML document containing the data needed for the interface to be invoked."

    I don't understand what that message "header" should be in PHP terms.

    To send the xml to UPS, so far I am using (I found this code somewhere, but don't know if I'm going in the right direction):
    PHP Code:
    $curl_handle curl_init(); 
    curl_setopt($curl_handleCURLOPT_URL"https://wwwcie.ups.com/ups.app/xml/Rate"); 
    curl_setopt($curl_handleCURLOPT_FOLLOWLOCATION1); 
    curl_setopt($curl_handleCURLOPT_RETURNTRANSFER1); 
    curl_setopt($curl_handleCURLOPT_POST1); 
    curl_setopt($curl_handleCURLOPT_POSTFIELDS$xml_request); 
    $response curl_exec($curl_handle) or die("There has been an error connecting to UPS"); 
    curl_close($curl_handle); 
    The XML data is contained in the var $xml_request...

    Now, I don't understand what I need to do to retreive the XML response sent by ups...

    Please help!...

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The response from UPS is in $response.

  3. #3


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
  •