Updating Facebook Profile FBML using setRefHandle, fb:ref and "infinate sessions".
Setting up an infinate session in CF is not difficult.
You need to echo the request.session_info.session_key to the screen and save it (somewhere). You also need a user id.
I have a scheduled task that triggers a file every hour, on the hour.
I like the setRefHandle because it allows me to update a cache on the facebook server instead of pulling or pushing content whenever there is an update. Even if the handle is the userID, the functionality is great!
In this examle, the handle name I have chosen is called "global_message" and the content is the date and time when the script was last accessed.
facebook = CreateObject("component","FacebookRestClient").init(argumentCollection=request.config);
request.key = "[saved session ID]";
request.uid = "[userID]";
</cfscript>
<cfoutput>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<InvalidTag http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<cfscript>
res = facebook.fbml_setRefHandle("global_message", "#DateFormat(Now())# #TimeFormat(Now())#", request.key);
</cfscript>
</body>
</html>
</cfoutput>
The function to add to the facebook CFC is this:
Created by Cory Johnson on June 13, 2007
For help with this, contact cory@dragonflybytes.com
--->
<!--- cache controls --->
<cffunction name="fbml_setRefHandle" access="public" output="false" returntype="any">
<cfargument name="app_handle" type="string" required="yes" />
<cfargument name="fbml" type="string" required="yes" />
<cfargument name="sess_key" type="string" required="yes" />
<cfset var result = "" />
<cfset var params = StructNew() />
<cfset params["handle"] = arguments.app_handle/>
<cfset params["fbml"] = arguments.fbml/>
<cfset params["session_key"] = arguments.sess_key/>
<cfset result = callMethod("facebook.fbml.setRefHandle", params) />
<cfreturn result />
</cffunction>
In my facebook application, I have set the default FBML to this"
