5 Replies - 12742 Views - Last Post: 24 December 2008 - 04:33 PM

#1 CrazedAzn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 26-September 07

Calling another website's function

Post icon  Posted 27 May 2008 - 07:02 AM

Hey, I'm currently working on a project for a corporation that involves tracking numbers. I'm trying to write an application that will take a tracking number and call another website's form or function. For example:

I have a UPS Tracking Number "xxx-xxx-xxx" and I input this information to my application. This application will then call the UPS Tracking website and parse the information and show the information to the client / user.

Another example is the google flight tracking gadget. Input your flight number and it spits out your flight information, using a website called flights.com.

So my question is, how do I go about doing this in Javascript (and other languages such as C# since I will also be developing another application that takes tracking numbers in batches).

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Calling another website's function

#2 Winstinology  Icon User is offline

  • I'm pretty good with a laser mouse..
  • member icon

Reputation: 7
  • View blog
  • Posts: 958
  • Joined: 08-May 08

Re: Calling another website's function

Posted 27 May 2008 - 01:49 PM

I don't know of any other way you can call functions from another page in Javascript, but you can hold all of your functions in a separate Javascript file and call them from there, using the <link rel href type/> method up in the header section. In C# you can do this by creating a separate class in the app folder... I'm not sure if this helps at all...
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Calling another website's function

Posted 27 May 2008 - 02:13 PM

Well you're going to have to contact, say UPS, and get their API which allows you to interact with their system and retrieve data from it.

As for the airlines, you'll need a GDS system, like Amadeus, which gives you access to the API needed to retrieve information from the airlines systems.
Was This Post Helpful? 0
  • +
  • -

#4 robbickel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 21-December 08

Re: Calling another website's function

Posted 21 December 2008 - 12:11 PM

you need to apply for access to their api then you will use your login information to build an xml request and use the webrequest object to push the request to a url they provide, they provide a development url for testing as well so make sure you use the right one for what stage you are in. then you read the response. I like to read it into a binary array so i can deserialize the response but you can use an xml reader and parse the nodes. if you are deserializing write me and i may share my class. if you want to create your own class just use the xml example they provide you with and convert it using xsd .. ie xsd example.xml then xsd /classes example.xsd will generate example.cs

PM if you need help



ps i realize this is late... this is more for anyone else who stumbles across this
Was This Post Helpful? 0
  • +
  • -

#5 ~NJ  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 9
  • View blog
  • Posts: 52
  • Joined: 22-December 08

Re: Calling another website's function

Posted 23 December 2008 - 05:06 AM

As for calling a function from another site, it should theoretically be possible. You'd need to import the JS file from the other site but aside from that I can't see why it isn't possible...
Was This Post Helpful? 0
  • +
  • -

#6 Mike007  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 332
  • Joined: 30-August 07

Re: Calling another website's function

Posted 24 December 2008 - 04:33 PM

View Post~NJ, on 23 Dec, 2008 - 04:06 AM, said:

As for calling a function from another site, it should theoretically be possible. You'd need to import the JS file from the other site but aside from that I can't see why it isn't possible...


It not only possible, it is widely used. Even on this very site there are quite a few javascript files included from other domains, like google for example. It's used for advertisements placements a lot. Yahoo, google and live all have scripts that other websites on the web use on their own pages.

The only problem I see with this particular situation is that AJAX does not allow for cross domain functionality for security reasons. I.e. you will not be able to get any information back from the UPS website using Javascript alone. So you will need a server side script, ASP.NET is probably a good choice since it is supposed to work well with C#. But, I never used it. All the server side script will do is make a cross domain request for you from the UPS website for an XML document probably, which you will then parse as suggested already. The parsing will be done in Javascript. But like the others said, you will need their API to do all that and to know what their xml document is going to look like.

Hope that helps.
Was This Post Helpful? 1

Page 1 of 1