Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>this is a way to connect to Facebook using Graph API. Everything is explained in comment. This is actually the connecting to facebook, no posting to walls or anything. That part can be found below this class.</p> <pre><code>package com.DAL { import com.facebook.graph.Facebook; import flash.events.Event; import com.facebook.graph.data.FacebookSession; import flash.events.EventDispatcher; import flash.events.MouseEvent; import com.fbLoginButton; import com.adobe.serialization.json.JSON; public class FBConnect extends EventDispatcher { /****************************************** * Variables ******************************************/ private var _applicationID:String; private var _extendedPermissions:Object; /****************************************** * Constants ******************************************/ public static const CONNECTED:String = "CONNECTED"; /****************************************** * Properties ******************************************/ public function get applicationID():String { return _applicationID; } /****************************************** * Constructor ******************************************/ public function FBConnect() { super(); //Set applicationid _applicationID = "YOUR_ID"; //Set permissions to ask for _extendedPermissions = {perms:"read_stream, publish_stream, user_about_me, read_friendlists, user_photos"}; //Initialize facebook Facebook.init(_applicationID); } /****************************************** * Methods ******************************************/ public function login(e:MouseEvent):void { Facebook.login(handleLogin, _extendedPermissions); } private function handleLogin(response:Object, fail:Object):void { dispatchEvent(new Event(CONNECTED)); } } } </code></pre> <p>That should take care of connecting to facebook. If you want to post to walls or anything, you can find a small example below.</p> <pre><code> /****************************************** * Constructor ******************************************/ public function FBLogic() { super(); _connect = new FBConnect(); _connect.addEventListener(FBConnect.CONNECTED, startLoaders); initLoaders(); } /****************************************** * Methods ******************************************/ ... public function post(message:String):void { var _params:Object = new Object(); _params.access_token = Facebook.getSession().accessToken; _params.message = message; Facebook.api("/" + _userID + "/feed", messagePosted, _params, "POST"); } public function messagePosted(response:Object, fail:Object):void { dispatchEvent(new Event(MESSAGEPOSTED)); } public function login(e:MouseEvent):void { var _loginButton:fbLoginButton = e.target as fbLoginButton; _loginButton.alpha = 0; _loginButton.visible = false; _connect.login(e); } </code></pre> <p>If this doesn't do the trick you might have forgotten to add some code to your html file. Be sure to add the following code to the head of your html file:</p> <pre><code>&lt;script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt; </code></pre> <p>And you also need a div called fb-root, declared like this.</p> <pre><code>&lt;body&gt; &lt;div id="fb-root"&gt;&lt;/div&gt; &lt;div id="flashContent"&gt; &lt;/div&gt; &lt;/body&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload