We help IT Professionals succeed at work.

Help with an API for UPS

toolminator
toolminator asked
on
This is my first whack at a cgi interface to UPS's  online tracking utilities, and none of my books cover API's and online documentation is even less help.

If someone could offer some assistance, it would be MOST appreciated....

This is what I've got so far.....

use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->agent("AgentName/0.1 " . $ua->agent);

# Create a request
my $req = new HTTP::Request POST => 'https://www.ups.com/ups.app/xml/Rate';
   $req->content_type('application/x-www-form-urlencoded');
   $req->content('match=www&errors=0');

# Pass request to the user agent and get a response back
my $res = $ua->request($req);


# Check the outcome of the response
  if ($res->is_success) {
     print $res->content;
  } else {
     print "Error\n";
  }


This was a tid bit that I managed to scrounge together starting out, but with the amount of variables having to be sent in the request and then recieved in the response, is going to result in some pretty sloppy code.

I'm hoping someone has done something similar and can give me an example of sending several variables in POST format during the request and then recieving several variables in the response.

Thankx all


Comment
Watch Question

CERTIFIED EXPERT
Commented:
toolminator,

"..If someone could offer some assistance, it would be MOST appreciated......"

Can you pl. explain in plain english what exactly you are trying to do?

E.g. i want to go to site.com, submit a form with these values etc.....

i have used a simple script to extract data, submit forms & get their return values for more than 2 yrs now.

With your clear answer, i can customize that script to fit your requirements.

Do let me know.

Thanks,

Author

Commented:
Well, I do appreciate your response.... but I did manage to get the API doing what I needed it to do
after piecing together some of the answers from the previously asked questions (hours of reading).

Thankx for the thought anyway, and since you were the only one attempting to try and answer, you can have the points too.....

Nat
CERTIFIED EXPERT

Commented:
toolminator,

Glad to know that you got the solution you were looking for.

In the future, i would suggest you delete the question as that will save you the points & also ensure that the experts has earned the points.

Thanks,

Explore More ContentExplore courses, solutions, and other research materials related to this topic.