iframe header
  • Join FlightAware (Why Join?)
  • Login
  • US Flag 
04:43AM EDT

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: can't call methods with asp
PostPosted: Sun Jun 10, 2012 8:43 pm 
Offline

Joined: Sat Jun 09, 2012 6:22 pm
Posts: 5
Code:
      sUrl = "http://flightxml.flightaware.com/soap/FlightXML2/FlightInfo"
      data = "ident=AA59&howMany=1&offset=0"
      sUser = "sss"
      sKey = "ttt"
      
      Set XmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
       XmlHttp.Open "Post", sUrl, false

      
       XmlHttp.SetRequestHeader "Content-Type", "application/xml; charset=UTF-8"
       'XmlHttp.SetRequestHeader "Accept", "application/xml; charset=UTF-8"
      xmlhttp.setRequestHeader "Content-Length", Len(data)
      xmlhttp.SetRequestHeader "Authorization", "Basic " & Base64Encode(sUser & ":" & sKey )
       XmlHttp.Send(data)

      'response.write(XmlHttp.ResponseText)
      'response.ContentType ="text/plain"
      if XmlHttp.Status = 200 then
         Response.Write XmlHttp.responseXML.xml
      else
         response.write "Status:" & XmlHttp.Status & "<br/>"
         Response.Write "Info:" & XmlHttp.ResponseText
      end if


call methods with above code, but can't works. Show following info:

Method Not Implemented
Post to /soap/FlightXML2/FlightInfo not supported.

Anyone can help me?

Thanks & best regards.


Top
 Profile  
 
 Post subject: Re: can't call methods with asp
PostPosted: Mon Jun 11, 2012 12:29 pm 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 234
Location: FlightAware WHQ
SOAP requests must use /soap/FlightXML2/op as the endpoint, and the request must be encoded as an XML document in the standard SOAP request body format.

I recommending using the JSON interface to FlightXML instead, if you are needing to generate and parse the bodies manually.

Download the json2.js parser from Douglas Crockford's JSON in JavaScript project at https://github.com/douglascrockford/JSON-js

Save the following file as test.asp, but substitute your actual username and API key:

Code:
<script language="javascript" runat="server" src="json2.js"></script>
<%
Dim postData, httpRequest, jsonResponse

postData = "airport=KAUS"
postData = postData & "&howMany=10"
postData = postData & "&filter=airline"

Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
httpRequest.Open "POST", "http://flightxml.flightaware.com/json/FlightXML2/Arrived", False, "YOUR_USERNAME", "YOUR_APIKEY"
httpRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.Send postData

If httpRequest.status = 200 Then
    Set jsonResponse = JSON.parse(httpRequest.responseText)

    For Each flight In jsonResponse.ArrivedResult.arrivals
        Response.Write("Flight " & flight.ident & " is arriving from " & flight.origin & "<br>")
    Next
Else
    Response.Write("Error occurred")
End If

Set httpRequest = Nothing
%>


Top
 Profile  
 
 Post subject: Re: can't call methods with asp
PostPosted: Mon Jun 11, 2012 8:11 pm 
Offline

Joined: Sat Jun 09, 2012 6:22 pm
Posts: 5
Sir,
Thank you very much for your reply first.

Just I have a questions, are you sure it can works?

I ask this is because I download all codes and run it, it show me following:
httpRequest.status: 401
httpRequest.ResponseText: Authentication Required


I don't know why that happen, is that possible is caused of the wrong username or api key?

Thanks & best regards.


Top
 Profile  
 
 Post subject: Re: can't call methods with asp
PostPosted: Mon Jun 11, 2012 9:01 pm 
Offline
FlightAware Staff
bovineone - FlightAware user avatar

Joined: Wed Jul 27, 2005 3:00 am
Posts: 234
Location: FlightAware WHQ
That code is untested, so it may or may not work but I suspect it's very close to being complete.

However, you need to ensure that you are using a FlightXML API key and not your website password. If you do have an API key, you can sign up for one by visiting https://flightaware.com/commercial/flightxml/key and entering your billing information if prompted.


Top
 Profile  
 
 Post subject: Re: can't call methods with asp
PostPosted: Mon Jun 11, 2012 9:09 pm 
Offline

Joined: Sat Jun 09, 2012 6:22 pm
Posts: 5
Sir,
Thanks very much for your reply.
I wrote this code for others, the employer send me the apikey and username. He said that's right.

I don't want to create apikey for myself, because I don't need the serivice. If I can cancle the apikey(and the credit card info from flightaware.com), then I can try to get the key of myself.

And I donwnload c# and javascript sample code from flightaware.com, they all can't works with the username and apikey, and show the same wrong info.

Maybe it is caused by the wrong username or apikey? Maybe~~~~~~~ I don't know how to ensure that.

Anyway, thanks very much for your reply again.

Thanks & best regards,
--- zhangkai


Top
 Profile  
 
 Post subject: Re: can't call methods with asp
PostPosted: Mon Jun 11, 2012 10:53 pm 
Offline

Joined: Sat Jun 09, 2012 6:22 pm
Posts: 5
Hi Sir,
good news!!
I create a key of myself, and the code work great now!

So that issue is caused by the wrong username or apikey.

thanks very much for your help!

Thanks & best regards,
---zhangkai


Top
 Profile  
 
 Post subject: Re: can't call methods with asp
PostPosted: Mon Jun 11, 2012 10:55 pm 
Offline

Joined: Sat Jun 09, 2012 6:22 pm
Posts: 5
get the result like following:

Flight AAL2491 is arriving from KORD
Flight SWA367 is arriving from KPHX
Flight UAL272 is arriving from KIAD
Flight UAL1234 is arriving from KIAH
Flight AAL1452 is arriving from KDFW
Flight FLG3477 is arriving from KMEM
Flight UPS301 is arriving from MMMY
Flight AAL1202 is arriving from KDFW
Flight ASH2653 is arriving from KCLT
Flight SKW5301 is arriving from KORD


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
iframe sidebar


 

Airport Tracker/Info


-or-