<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 travelTime
Source realtime travel data from Google Maps
Step1:  Enter your Google Maps Directions API key below
Step2:  Enter your origin and destination
Step3:  Try to grab realtime traffic from Google
Step4:  Process response data
<ASSISTANT_TASK:>
Python Code:
import urllib, json, time
Explanation: travelTime
Source realtime travel data from Google Maps
End of explanation
apiKey=""
if not apiKey:
    print "Enter your API key for traffic data!"
    exit(1)
Explanation: Enter your Google Maps Directions API key below:
End of explanation
origin="Empire State Building, NY"
destination="One World Trade Center, NY"
Explanation: Enter your origin and destination:
End of explanation
params = urllib.urlencode(
    {'origin': origin, 
     'destination': destination, 
     'mode': 'driving', 
     'key': apiKey, 
     'departure_time':'now'})
url = "https://maps.googleapis.com/maps/api/directions/json?%s" % params
timestamp = int(time.time()) # capture when the request is made
try:
    response = urllib.urlopen(url)
except IOError, e:
    print e
if response.getcode() == 200:
    data = json.loads(response.read())
else:
    print "Error %s" % response.getcode()
    exit(1)
Explanation: Try to grab realtime traffic from Google:
End of explanation
if 'error_message' in data:
    print data['error_message']
    exit(1)
if not 'routes' in data or len(data['routes']) < 1:
    print "Route data not returned. Check locations?"
    exit(1)
elif not 'duration_in_traffic' in data['routes'][0]['legs'][0]:
    print "Traffic data not returned"
    exit(1)
else:
    print "%s,%s" % (timestamp, data['routes'][0]['legs'][0]['duration_in_traffic']['value'])
Explanation: Process response data
End of explanation
<END_TASK>