SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Jun 25, 2001, 13:51 #1
- Join Date
- May 2001
- Location
- Gilroy, CA
- Posts
- 35
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP XML & get - Can I do this 0r do I need Snoopy
Do I need snoopy to use Get?
The USPS offers this request as a valid request:
Http://SERVERNAME/ShippingAPITest.dll?API=Rate&XML=<RateRequest>
USERID="xxxxxxxx" PASSWORD="xxxxxxxx"><Package ID="0"><Service>
EXPRESS</Service><ZipOrigination>20770</ZipOrigination><ZipDestination>20852<
/ZipDestination><Pounds>10</Pounds><Ounces>0</Ounces><Container>None</Contain
er><Size>REGULAR</Size><Machinable></Machinable></Package></RateRequest>
if I put this into file($abovestring); (I did put the correct user and password and changed all double quotes to single quotes) it sends a request but ignores everything within<> so I get the following error:
Warning: file("Http://testing.shippingapis.com/ShippingAPITest.dll?API=Rate&XML=EXPRESS2077020852100NoneREGULAR") - No such file or directory in /home/sites/home/web/testxml.php on line 5
Is this a problem with the <> in the string, or is this not a valid way to send information with GET?
Thanks,
bernn
-
Jun 25, 2001, 13:58 #2
- Join Date
- Oct 2000
- Location
- Austin, TX
- Posts
- 1,438
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You need to urlencode() http://www.php.net/manual/en/function.urlencode.php it.
-
Jun 25, 2001, 14:00 #3
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Bernn I spent the better half of yesterday trying to figure this one out, but no such luck. I mean right on usps site is says those are valid get requests. But what I think is missing is a way to connect to the server and pass that xml request. I tried looking through the XML docs for PHP, but couldn't figure it out. I know a little further down the page in the usps docs it gives examples for ASP, Perl and Java, but none for PHP. I do want to figure out how it works so I will be trying some more, and will let you know if I figure it out.
Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Jun 26, 2001, 15:56 #4
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Bernn,
I got it all figured out for you. First get snoopy, it just makes life easier. http://sourceforge.net/projects/snoopy/
Here is the script I used and it worked perfect.
PHP Code:<?
include "Snoopy.class.inc";
$snoopy = new Snoopy;
$msg = '<RateRequest USERID="159JOHNC2479" PASSWORD="234VE51TI212">
<Package ID="0">
<Service>EXPRESS</Service>
<ZipOrigination>20770</ZipOrigination>
<ZipDestination>20852</ZipDestination>
<Pounds>10</Pounds>
<Ounces>0</Ounces>
<Container>None</Container>
<Size>REGULAR</Size>
<Machinable></Machinable>
</Package>
</RateRequest>';
$submit_url = "http://testing.shippingapis.com/ShippingAPITest.dll";
$submit_vars["API"] = "Rate";
$submit_vars["XML"] = $msg;
$snoopy->submit($submit_url,$submit_vars);
print "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
?>Please don't PM me with questions.
Use the forums, that is what they are here for.
-
Jun 27, 2001, 16:09 #5
- Join Date
- May 2001
- Location
- Gilroy, CA
- Posts
- 35
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank You
Your code works splendidly ... thanks for the help
Bernn
-
Jun 27, 2001, 16:14 #6
- Join Date
- Aug 2000
- Location
- San Diego, CA
- Posts
- 5,460
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No problem and see you at the Garlic Festival
Please don't PM me with questions.
Use the forums, that is what they are here for.
Bookmarks