Skip to content

Instantly share code, notes, and snippets.

@ejcx ejcx/flight.go
Created Mar 23, 2019

Embed
What would you like to do?
Flight Server
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"time"
)
var (
d []byte
)
func main() {
go func() {
for {
resp, err := http.Get("https://www.unitedwifi.com/portal/r/getAllSessionData")
if err != nil {
log.Println(err)
continue
}
buf, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Println(err)
continue
}
d = buf
time.Sleep(time.Second * 5)
}
}()
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s", d)
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
@mattKaczorowski

This comment has been minimized.

Copy link

mattKaczorowski commented Mar 23, 2019

Do you have a sample response? I wasn't able to catch your flight in time :).

@ejcx

This comment has been minimized.

Copy link
Owner Author

ejcx commented Mar 23, 2019

@mattKaczorowsk I was actually able to pull an example response out of my chrome cache. Here it is:

{
    "isPortalInitialized" : true,
    "flightOffersInternetService": true,
    "internetConnectionIsAvailable": true,
    "devicePlatform" : "Other",
    "host" : "www.unitedwifi.com",
    "IsLoggedIn": true ,
    "isSubscriptionAvailable": true,
    "internet": {
      "accessType": "FULL",
      "tier": "T2",
      "tierDescription": "Basic",
      "fulfilmentState": "ACTIVE",
      "orderState": "ACTIVE",
      "timeRemaining": 0
    }
        ,  
    "flifo": {
        "originAirportCode": "AUS",
        "originCity": "Austin, TX, US (AUS)",
        "originState": "",
        "destinationAirportCode": "SFO",
        "destinationCity": "San Francisco, CA, US (SFO)",
        "destinationState": "",
        "scheduledDepartureTimeLocal": "22 Mar 2019 6:24 PM",
        "scheduledArrivalTimeLocal": "22 Mar 2019 8:23 PM",
        "estimatedDepartureTimeLocal": "22 Mar 2019 8:45 PM",
        "estimatedArrivalTimeLocal": "22 Mar 2019 10:52 PM",
        "actualDepartureTimeLocal": "22 Mar 2019 8:36 PM",
        "actualArrivalTimeLocal": "01 Jan 0001 12:00 AM",
        "flightStatus": "In Flight - Estimated to Arrive 2 Hours 29 Minutes Late",
        "isFake": false,
        "flightNumber": "455",
        "flightGuid": "90ce9f8b-0452-87f2-e33f-d6dacb9ab52c",
        "timeRemainingToDestination": 54,
        "flightDurationMinutes" : 239,
        "flightMapPath": "/portal/images/map/TabletLandscape.png?1553316485",
        "scheduledDepartureTime": "6:24 p.m.",
        "actualDepartureTime": "8:36 p.m.",
        "scheduledArrivalTime": "8:23 p.m.",
        "estimatedArrivalTime": "10:52 p.m.",
        "departureGate": "31",
        "arrivalGate": "64",
        "departureTerminal": "",
        "arrivalTerminal": "Terminal 3",
        "departureConcourse": "",
        "arrivalConcourse": " Concourse E",
        "aircraftModel": "Airbus 320",
        "noseNumber": "4713",
        "equipmentCode": "20S",
        "airSpeedMPH": "58",
        "airSpeedKPH": "93",
        "windDirection": "WSW",
        "groundSpeedMPH": "487",
        "groundSpeedKPH": "783",
        "airTemperatureF": "",
        "airTemperatureC": "",
        "altitudeFt": "31991",
        "altitudeMeters": "9750"
    }
    
    	    ,
	    "weather": {
	        "currently": {
	            "day": "Fri",
	            "code": "26",
	            "currtempf": 55,
	            "currtempc": 13,
	            "lowtempf": 55,
	            "hightempf": 55,
	            "lowtempc": 13,
	            "hightempc": 13,
	            "text": "Cloudy"
	        },
	        "forecast": [
	        	            {
	                "day": "Sat",
	                "code": 32,
	                "lowtempf": 45,
	            	"hightempf": 58,
	            	"lowtempc": 7,
	            	"hightempc": 15,
	                "text": "Sunny"
	            },
	        	            {
	                "day": "Sun",
	                "code": 20,
	                "lowtempf": 51,
	            	"hightempf": 62,
	            	"lowtempc": 11,
	            	"hightempc": 17,
	                "text": "AM Fog/PM Clouds"
	            },
	        	            {
	                "day": "Mon",
	                "code": 12,
	                "lowtempf": 48,
	            	"hightempf": 58,
	            	"lowtempc": 9,
	            	"hightempc": 14,
	                "text": "AM Rain"
	            },
	        	            {
	                "day": "Tue",
	                "code": 26,
	                "lowtempf": 50,
	            	"hightempf": 60,
	            	"lowtempc": 10,
	            	"hightempc": 15,
	                "text": "Cloudy"
	            },
	        	            {
	                "day": "Wed",
	                "code": 12,
	                "lowtempf": 48,
	            	"hightempf": 57,
	            	"lowtempc": 9,
	            	"hightempc": 14,
	                "text": "Rain/Wind"
	            },
	        
	        "lastitem"
	        ]
	    }
    
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.