USPS Tracking API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maheswaran
    New Member
    • Mar 2007
    • 190

    USPS Tracking API

    Hi Friends,

    I need a USPS API tracking and here with i have attached two sample files to tracking the USPS postal service.

    On test1.php, You can check the XML value and result value by echo.On echo the xml, am not get the full url as API=TrackV2&XML =<TrackRequest USERID='468CMAF I3505'><TrackID ID='EJ958083578 US'></TrackID></TrackRequest>, i got only "API=TrackV2&XM L=" and see the result for this.

    Also have same problem on test.php. See the xml value and result.Can any body suggest any solution. For both of above issues i replaced xml value < than for &lt; and > for &gt;. You just comment the line 26 and uncomment the line 27 and see the xml and result. As well as you can see the test.php by adding comment on 26 and uncommenting on 27 line.

    User id & TrackIDs are valid and see the reference documents

    http://www.usps.com/webtools/htm/Track-Confirm.htm
    http://www.usps.com/webtools/htm/Development-Guide-v3-0b.htm

    Can you people tell where am i wrong.?
    Attached Files
  • HaLo2FrEeEk
    Contributor
    • Feb 2007
    • 404

    #2
    It looks like you're tying to pass XML characters (<, >) through a GET request. This won't work. If you must do it this way, try rawurlencode()-ing the XML data before attaching it to the URL, then when you recieve it you can rawurldecode() it.

    Also:



    Usage ID Restrictions. Be careful, you've posted your personal User ID to the internet, it's very possible your access to the API will now be revoked if anyone feels the inclination to steal that User ID from you.

    Comment

    • maheswaran
      New Member
      • Mar 2007
      • 190

      #3
      Hi thanks for your reply. i have no luck even using with rawurlencode

      Comment

      • HaLo2FrEeEk
        Contributor
        • Feb 2007
        • 404

        #4
        Well I ran test1.php and I got some HTTP headers and proper tracking data for the package ID "EJ958083578US" . The package was delivered at 8:10 am on June 1 in Wilmington DE 19810. If all you're worried about is that the URL prints properly to the page then change line 29 to this:

        echo "PRINT XML -> ".htmlentities( $data)."<br><br >";

        And it'll work.

        Comment

        • maheswaran
          New Member
          • Mar 2007
          • 190

          #5
          hi,

          Am not get this answer.Can you post your code which ran?

          Comment

          • HaLo2FrEeEk
            Contributor
            • Feb 2007
            • 404

            #6
            No, Bytes isn't a place for people to write your code for you. I downloaded to.zip, which you attached to your first post. I didn't change anything, line 26 was uncommented and line 27 was commented. I loaded up test1.php and I got a page that had this line:

            Code:
            PRINT XML -> API=TrackV2&XML=
            And a bunch of valid tacking data after a <hr> tag.

            I did exactly what I told you to do in my previous post and I got the same page, except the first line was this:

            Code:
            PRINT XML -> API=TrackV2&XML=<TrackRequest USERID='468CMAFI3505'><TrackID ID='EJ958083578US'></TrackID></TrackRequest>
            Again, if you only want to get the URL to display correcly on the page, then re-read my previous post, the part where I tell you about changing line 29. The code works and you're getting proper tracking data, so I assume that you're only worried about the URL printing on the page correctly.

            Comment

            Working...