Created
December 1, 2009 20:59
-
-
Save coderberry/246642 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'net/http' | |
| require 'uri' | |
| # Create te http object | |
| url = "http://POST_URL_HERE/api/create_custom_order" | |
| uri = URI.parse(url) | |
| http = Net::HTTP.new(uri.host, uri.port) | |
| xml = <<-EOF | |
| <order> | |
| <company-id>1</company-id> | |
| <shipping-profile>t1</shipping-profile> | |
| <shipping-full-name>John Doe</shipping-full-name> | |
| <shipping-care-of/> | |
| <shipping-address-1>123 Easy St</shipping-address-1> | |
| <shipping-address-2/> | |
| <shipping-city>Eau Claire</shipping-city> | |
| <shipping-state>WI</shipping-state> | |
| <shipping-zip>77593</shipping-zip> | |
| <shipping-country>US</shipping-country> | |
| <items> | |
| <item> | |
| <inventory-item-id>1</inventory-item-id> | |
| <quantity>1</quantity> | |
| </item> | |
| </items> | |
| </order> | |
| EOF | |
| # Set Headers | |
| headers = { | |
| 'Referer' => 'http://www.my_url_here.com', | |
| 'Content-Type' => 'text/xml', | |
| 'Host' => uri.host, | |
| 'Content-Length' => xml.length.to_s | |
| } | |
| # Post the request | |
| resp, data = http.post(uri.path, xml, headers) | |
| # Output the results | |
| puts 'Code = ' + resp.code | |
| puts 'Message = ' + resp.message | |
| resp.each { |key, val| puts key + ' = ' + val } | |
| puts data | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment