A gem to help integrating with TripIt API. Please see the LICENSE for copyright information.
The gem follows the typical oAuth process.
It uses consumer_key and consumer_secret which are provided by TripIt when you register your app in the developer section.
The first step of the process would be to get authorization from the specific user. set_host
To that end, we first get a request token which is sort of an unauthorised token.
With that unauthorised token we redirect the user to the authorisation URL
https://www.tripit.com/oauth/authorize?oauth_token=<oauth_token>&oauth_callback=<oauth_callback>
The oauth_callback obviously only works for web application (no mobile).
Finally, when the application gets the control again, we get an authorised token and make the actual call
Add tripit
to your Gemfile.
gem 'tripit', :git => "git://github.com/gonfva/tripit_api.git"
oauth_credential = TripIt::OAuthCredential.new(
consumer_key, consumer_secret)
t = TripIt::API.new(oauth_credential, api_url)
request_token = t.get_request_token
print "request token: #{request_token.token}\n"
print "request secret: #{request_token.token_secret}\n"
oauth_credential = TripIt::OAuthCredential.new(
consumer_key, consumer_secret,
request_token, request_token_secret)
t = TripIt::API.new(oauth_credential, api_url)
authorized_token = t.get_access_token
print "authorized token: #{authorized_token.token}\n"
print "authorized secret: #{authorized_token.token_secret}\n"
Get request (list of trips)
oauth_credential = TripIt::OAuthCredential.new(
consumer_key, consumer_secret,
authorized_token, authorized_token_secret)
t = TripIt::API.new(oauth_credential, api_url)
# print t.list.trip.to_xml.to_s
# Or with arguments
print t.list.trip({'include_objects' => 'true'}).to_xml.to_s
Post request (new trip)
trip_xml = "<Request><Trip>" \
"<start_date>2009-12-09</start_date>" \
"<end_date>2009-12-27</end_date>" \
"<primary_location>New York, NY</primary_location>" \
"</Trip></Request>"
oauth_credential = TripIt::OAuthCredential.new(
consumer_key, consumer_secret,
authorized_token, authorized_token_secret)
t = TripIt::API.new(oauth_credential, api_url)
puts t.create(trip_xml).to_xml.to_s
You can get more information from the API site