I have a ColdFusion web page that gets refreshed by my server every x minutes. That script checks various feeds (Facebook, YouTube, and internal news items) and builds a merged feed in chronological order. The Facebook part just pulls post data from our Facebook Fan Page. I can do this with the OAuth token provided when I authorize my app from our account.
The token expires every couple of months or something I think. It lasts a pretty long while, and I have read there is no way to auto Authorize an app. I however keep reading about these refresh tokens or something but can't get a clear grasp on how they work.
I would like my script to attempt to get the JSON data from Facebook, and if the token expires every so often, re-request it, but it appears that just hitting the graphs.facebook.com/oauth/authorize link again doesn't work because obviously you need to be logged in for it to authorize something.
Is there anyway I can internally reauthorize or refresh my token server side. This Facebook app, site, and Facebook users are all completely internal. There used to be an RSS feed of facebook pages, but Facebook changes stuff all of the time and I don't see it anymore.
All I really need is the data from the timeline/feed for my Facebook Company Page.
Any solutions or suggestions would be helpful.
ANSWER: This is what I ended up using to get the data based on the content. Below grabs the token, then uses the token to grab the feed data and puts it into a struct. It may not be the most concise way, but it works.
<cfhttp url="https://graph.facebook.com/oauth/access_token?client_id=[CLIENTID]&client_secret=[CLIENTSECRET]&grant_type=client_credentials&redirect_uri=[URL] "
result="AccessHTTP" />
<cfset token = replace(AccessHTTP.Filecontent,"access_token=", "", "ALL")>
<cfhttp result="result" url="https://graph.facebook.com/[USERNAME]/posts?access_token=#token#" ></cfhttp>
<cfset Facebook = deserializeJSON(result.filecontent).data />
I just grab the token every time my page loads..
<cfhttp url="https://graph.facebook.com/oauth/access_token?client_id=your_client_id&client_secret=your_secret&grant_type=client_credentials" result="ThisHTTP" />
<cfset this.access_token = '#replace(ThisHTTP.Filecontent,"access_token=", "", "ALL")#'>
///Run Your Code Below using #this.access_token# when you need it. ///
https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=YOUR_CLIENT_ID&redirect_uri=REDIRECT_URL&scope=offline_access
The Facebook documentation is terrible in my opinion and no where did I see the format you listed above. I will have to try that out - Leeish 2012-04-05 16:42