Coldfusion implementation code (supplied)

32 views
Skip to first unread message

AlanG

unread,
Aug 26, 2010, 8:13:31 AM8/26/10
to Janrain Developers
I just converted the php example to coldfusion and thought i'd share
the code in case anyone else wants it in the future.
<!---rpx.cfm (or whatever else specified)---->
<cfset variables.rpxApiKey = 'your-rpxkey-here'>
<cfif isdefined('form.token')>
<!--- STEP 1: Extract token POST parameter --->
<cfset variables.token = form.token>
<!--- STEP 2: Use the token to make the auth_info API call --->
<cfset variables.post_data = arraynew(2)>
<cfset variables.post_data[1][1] = 'token'>
<cfset variables.post_data[1][2] = 'apikey'>
<cfset variables.post_data[1][3] = 'format'>
<cfset variables.post_data[2][1] = form.token>
<cfset variables.post_data[2][2] = rpxApiKey>
<cfset variables.post_data[2][3] = 'json'>
<cfhttp url="https://rpxnow.com/api/v2/auth_info" method="post">
<cfhttpparam name="token" value="#form.token#" type="formfield" >
<cfhttpparam name="apiKey" value="#variables.rpxApiKey#"
type="formfield" >
<cfhttpparam name="format" value="json" type="formfield" >
</cfhttp>
<!--- STEP 3: Parse the JSON auth_info response --->
<cfset variables.auth_info = DeserializeJSON(cfhttp.fileContent)>
<cfif variables.auth_info['stat'] eq "ok" >
<!--- STEP 3 Continued: Extract the 'identifier' from the response ---
>
<cfset variables.profile = variables.auth_info['profile']>
<cfset variables.identifier = variables.profile['identifier']>
<cfif isdefined('variables.profile["photo"]')>
<cfset variables.photo_url = variables.profile['photo']>
</cfif>
<cfif isdefined('variables.profile["displayName"]')>
<cfset variables.name = variables.profile['displayName']>

</cfif>
<cfif isdefined('variables.profile["email"]')>
<cfset variables.email = variables.profile['email']>

</cfif>
<!--- just for dev / testing--->
Output Everything:<br/>
<cfdump var="#variables.auth_info#">
<!---STEP 4: Use the identifier as the unique key to sign the user
into your system.
This will depend on your website implementation, and you should
add your own
code here. Maybe cflogin for coldfusion --->
<cfelse>
<!--- an error occurred gracefully handle the error.
Hook this into your native error handling system.--->
<cfoutput>Not logged in, An error occured,
#variables.auth_info['err']['msg']#, <a href="#application.home#/
login">try again</a></cfoutput>
</cfif>
<cfelse>
<cflocation addtoken="false" url="#application.home#/login">
</cfif>

Matt Riley

unread,
Aug 26, 2010, 3:05:51 PM8/26/10
to Janrain Developers
This is awesome, I'm working on a CF implementation right now. You
should put this up on http://www.riaforge.org/ too.

Ivan Pulleyn

unread,
Aug 26, 2010, 4:51:35 PM8/26/10
to rpx-dev...@googlegroups.com

Thanks for posting this code. If you have a permanent link for it, let me know and I'll add it to the wiki.

Ivan...

--
You received this message because you are subscribed to the Google Groups "Janrain Developers" group.
To post to this group, send email to rpx-dev...@googlegroups.com.
To unsubscribe from this group, send email to rpx-developer...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rpx-developers?hl=en.




--
Janrain Ivan Pulleyn | Software Engineer


AlanG

unread,
Sep 2, 2010, 2:02:53 PM9/2/10
to Janrain Developers
Here's a blog entry with the code in.

http://agilby.blogspot.com/2010/09/janrian-engage-coldfusion.html

Thanks Ivan, and no problem, as they say it's good to share.

Al
> > rpx-developer...@googlegroups.com<rpx-developers%2Bunsubscribe@go oglegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rpx-developers?hl=en.
>
> --
> *Janrain | Ivan Pulleyn* | *Software Engineer*
> *
> *
Reply all
Reply to author
Forward
0 new messages