I downloaded the sample ManualFacebookTest.mxml, and it does not work
for me. I tried using my own api_key and secret, and I even tried the
supplied sample api_key and secret. Still, it does not work. I am
able to get the correct auth_token from the response, but it still
fails. Does anybody have any idea how to fix this?
Thanks,
Andrew
at Mixbook dot com
This error was a result of my auth_token methodology. I was using the
auth_token from the Auth.createToken() method, but I should have been
using the auth_token that gets posted to my callback URL after the
login screen.
It is not a bug.
Andrew
On Aug 23, 12:02 pm, Andrew Laffoon <andrew.laff...@gmail.com> wrote:
> Guys,
>
> Thiserrorwas a result of my auth_token methodology. I was using the
Run the main class. The flash window will launch. This will then
automatically take you to facebook in your browser. If you are not
logged it Facebook will prompt u to do so. After logging in it'll jump
you back to you callback url as specified in your Facebook Application
setting in Facebook.
You might require the swf you have made to be running on a web server. i.e.
http://localhost/facebookApp/index.html
Make sure u set your api_key and secret in the FacebookConfig class.
Regards,
Ric Moore
-------------------------------------------------------------------------
package com.bedroomlab.facebookApp {
import flash.display.Sprite;
import com.bedroomlab.facebook.GenericFacebookAuthentication;
import com.bedroomlab.facebook.inviteFriends.InviteFriends;
import flash.events.Event;
import com.adobe.webapis.facebook.FacebookService;
import flash.display.LoaderInfo;
public class FacebookApp extends Sprite {
private var facebookSession:GenericFacebookAuthentication
private var facebookService:FacebookService;
public function FacebookApp() {
trace("MakeOverApp.MakeOverApp()");
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
trace("paramObj.auth_token: "+paramObj.auth_token);
facebookSession = new GenericFacebookAuthentication(
FacebookAppConfig.API_KEY,
FacebookAppConfig.SECRET_KEY,
paramObj.auth_token);
facebookSession.addEventListener(Event.COMPLETE, init);
}
private function init(e:Event):void {
facebookService = facebookSession.facebookService;
/* TYPE YOUR OWN CODE IN FROM HERE */
}
}
}
-------------------------------------------------------------------------
package com.bedroomlab.facebook {
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.events.EventDispatcher;
import com.adobe.webapis.facebook.FacebookService;
import com.adobe.webapis.facebook.events.FacebookResultEvent;
import com.adobe.webapis.facebook.AuthSession;
import flash.events.Event;
public class GenericFacebookAuthentication extends EventDispatcher {
private var _facebookService:FacebookService;
public function GenericFacebookAuthentication(api_key:String,
secret_key:String, auth_token:String=null) {
// create service
_facebookService = new FacebookService(api_key);
_facebookService.secret = secret_key;
// check to see if the user has logged in (this must be passed in
from a _root var
if (auth_token != null) {
// user has logged in, get the session key
getSession(auth_token);
}
else {
// user not logged in, fetch a token for
_facebookService.addEventListener(FacebookResultEvent.AUTH_CREATE_TOKEN,
redirectToLogin);
facebookService.auth.createToken();
}
}
private function redirectToLogin(e:FacebookResultEvent):void {
_facebookService.auth_token = String(e.data);
navigateToURL(new
URLRequest(_facebookService.getLoginURL(_facebookService.auth_token)));
}
private function getSession(session_key:String):void {
_facebookService.addEventListener(FacebookResultEvent.AUTH_GET_SESSION,
finishAuthenticating);
_facebookService.auth.getSession(session_key);
}
private function finishAuthenticating(e:FacebookResultEvent):void {
var authSession:AuthSession = AuthSession(e.data);
_facebookService.session_key = authSession.session_key;
dispatchComplete();
}
public function get facebookService():FacebookService {
return _facebookService;
}
private function dispatchComplete():void {
dispatchEvent(new Event(Event.COMPLETE));
}
}
}
-------------------------------------------------------------------------
package com.bedroomlab.facebookApp {
public class FacebookAppConfig {
public static var API_KEY:String = "XXX";
public static var SECRET_KEY:String = "XXX";
I *am* using the auth_token passed to me from the facebook login url -
how do you pass it in to the facebook object? Like this?
fb = facebook.Facebook('abcdefghik', 'xxxabcdefghik', 'zzzabcdefghik')
(all values assumed of course) - Does any argument need to be a name/
value pair?
Thanks
Sami