Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save earth2marsh/664093 to your computer and use it in GitHub Desktop.
Save earth2marsh/664093 to your computer and use it in GitHub Desktop.
How to set up your local development machine to use the Apigee Heroku or Facebook add-on
# How to set up your local development machine to use the Apigee Heroku or Facebook add-on
if ENV['APIGEE_TWITTER_API_ENDPOINT']
@@twitter_api = ENV['APIGEE_TWITTER_API_ENDPOINT']
else
# Get this value from Heroku.
# Once you have enabled the addon, boot up the 'heroku console' and run the following:
# puts ENV['APIGEE_TWITTER_API_ENDPOINT']
# (or replace with the configvar of your Apigee endpoint according to the relevant add-on, see their docs)
# this will spit out your correct api endpoint
# note that Apigee changed the endpoint pattern from a dotted-tri to a dotted-duo for better SSL support
@@twitter_api = "twitter-api-appXYZABC.apigee.com"
end
# build the endpoint based on the add-on supplied configvar
@endpoint = 'http://' + @@twitter_api
# initialize with sample variables
ctoken = 'your_consumer_token'
csecret = 'your_consumer_secret'
atoken, asecret = ["14142354-mykey", "mysecret"]
oauth = Twitter::OAuth.new(ctoken, csecret, :api_endpoint => @endpoint)
oauth.authorize_from_access(atoken, asecret)
client = Twitter::Base.new(oauth)
@user = client.user('heroku') # calls user/show on @heroku via Apigee
@earth2marsh
Copy link
Author

updated to reflect the improved endpoint pattern defaults (see comments)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment