Last active
August 29, 2015 14:12
-
-
Save Bersam/88d85b06fb554918396c to your computer and use it in GitHub Desktop.
Allmyles Sample For Python2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests, json | |
api_key = "12345678-1234" | |
api_url = "http://somewhere.com" | |
data = json.dumps({ | |
'fromLocation': 'BUD', | |
'toLocation': 'LON', | |
'departureDate': '2014-12-29T00:00:00Z', | |
'resultTypes': 'default', | |
'returnDate': '2014-01-07T00:00:00Z', | |
'persons': [{ | |
'passengerType': 'ADT', | |
'quantity': 1 | |
}], | |
'preferredAirlines': ['BA'] | |
}) | |
headers = {'X-Auth-Token': api_key, | |
'Content-Type': 'application/json', | |
'Accept': 'application/json' | |
} | |
url = "%s/flights" % api_url | |
r = requests.post(url, data=data, headers=headers) | |
print r.status_code | |
print r.text | |
print r.json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment