Last active
December 15, 2015 03:19
-
-
Save Molnfront/5193571 to your computer and use it in GitHub Desktop.
A StackMob test implementation of Harry Klein´s (http://oauth.riaforge.org/) oAuth for ColdFusion. It uses oAuth 1.0 to read a list of markets. Tested on Railo Server 4.0.2, with PostgreSQL on OSX 10.7.5. For this to work you do not need a database. If you do you have to add tables manually in pqAdmin, the db script does not work in Railo.
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
<cfprocessingdirective pageencoding="utf-8" /> | |
<!--- cfcontent is also important for unicode ---> | |
<cfcontent type="text/html charset=utf-8"> | |
<!--- set up the parameters ---> | |
<cfset sConsumerKey = 'yourPublickey'> <!--- Paste your dev or prod keys here ---> | |
<cfset sConsumerSecret = 'youPrivatekey'> <!--- Paste your dev or prod keys here ---> | |
<cfset OAUTH_VERIFIER = '' /> <!--- You get back these when doing oauth registration ---> | |
<cfset token = '' /> <!--- You get back these when doing oauth registrationt ---> | |
<cfset tokenSecret = '' /> <!--- You get back these when doing oauth registration ---> | |
<!--- set up the required objects including signature method---> | |
<cfset oReqSigMethodSHA = CreateObject("component", "oauth.oauthsignaturemethod_hmac_sha1")> | |
<cfset oToken = CreateObject("component", "oauth.oauthtoken").init(sKey = token, sSecret = tokenSecret)> | |
<cfset oConsumer = CreateObject("component", "oauth.oauthconsumer").init(sKey = sConsumerKey, sSecret = sConsumerSecret)> | |
<cfset oReq = CreateObject("component", "oauth.oauthrequest").fromConsumerAndToken( | |
oConsumer = oConsumer, | |
oToken = oToken, | |
sHttpMethod = "GET", | |
sHttpURL = 'https://api.stackmob.com/markets?_expand=0')> <!--- For now, just trying to get the market info, change it to you own url. ---> | |
<cfset oReq.signRequest( | |
oSignatureMethod = oReqSigMethodSHA, | |
oConsumer = oConsumer, | |
oToken = oToken)> <!--- Sign the request ---> | |
<cfhttp url="#oReq.GETNORMALIZEDHTTPURL()#" method="get"> | |
<cfhttpparam encoded="no" type="CGI" name="accept" value="application/vnd.stackmob+json; version=0"> | |
<cfhttpparam type="header" name="authorization" value="#oReq.TOHEADER()#" /> | |
</cfhttp> | |
<cfdump var="#cfhttp#" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment