Why is the Actionscript API () not working?

I am calling com.facebook.graph.Facebook.init (APP_ID, loginHandler);

to login to facebook using the ActionScript api (as explained in this lesson: http://www.adobe.com/devnet/facebook/articles/flex_fbgraph_pt4.html ). But he seems to be doing nothing.

Looking at the source of the API, the only call made to JS is ExternalInterface.call ('FBAS.init', JSON.encode (parameters));

Two JavaScript libraries that are required:

http://connect.facebook.net/en_US/all.js FBJSBridge.js 

However, I cannot find a link to FBAS in these libraries. Do I even use the right libraries? Is there another reason I skipped why FBAS does not exist? or even why calling the Facebook.init () function does nothing?

+4
source share
6 answers

FBJSBridge.js is built into the SDK. Take a look at com.facebook.graph.core.FacebookJSBridge.as and you will see that the entire javascript block, which was FBJSBridge.js, is bound to the ExternalInterface in the com.facebook.graph.Facebook.as constructor.

I struggled with this all day. I watched the http GET generated by Facebook.init () and it looks like it just waits until the time runs out, and at that moment another GET appears. He never returns normally. I tried APPID, APIKEY and all kinds of combinations of parameters, but I never saw it return. I must conclude that it means working. If not, how does it work .: - /

In any case, you will see inside FBAS in this JS block in FacebookJSBridge.as, which triggers a subscription to the event "auth.sessionChange", which calls Facebook.handleSessionChange (). You can see that the callback is being called here. The trick is that this is what sessionChanges is called at any time. Therefore, even if the next time this event is not triggered due to a response from FB.init (), your callback will still be called to this point.

If you set your own handler for "auth.sessionChange" before you call Facebook.init (), and you set the cookie to true, after the cookie is created, you will receive a sessionChange event, starting to call you init. The initial call has not yet been called because the GET never receives a RESPONSE.

 Facebook.addJSEventListener("auth.sessionChange", onSessionChange); Facebook.init(_appID, onInitFacebookConnect, {cookie: true, appId: _appID, perms: "user_birthday,read_stream,publish_stream"}); 

The examples you find in this tutorial may work, but not what you want to use when co-creating the application. Otherwise, you will always press the button to call fbconnect. It seems that oauth2 will be a way to get the desired behavior when you do not need to press a button each time to "connect". You can get the sessionkey from oauth2 and then use Flash / Facebook GRAPHSDK or JS depending on what is most convenient for what you are trying to do.

This may help: http://blog.yoz.sk/2010/05/facebook-graph-api-and-oauth-2-and-flash/

+4
source

There seem to be several reasons why this fails. See the following links:

http://code.google.com/p/facebook-actionscript-api/issues/detail?id=165

http://www.pastrytech.com/willy/FacebookActionScript3SDKExample.html

For me it was that the order of the script tags is incorrect in the shell file that is provided in the Adobe tutorial.

Make sure the Facebook JS library is added before swfobject. That is, make sure that the script tags are in the following order:

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script> 
+2
source

It seems that FBAS.getSwf() uses the name swf in its call to document.getElementById .

So, if you specify an identifier, but not a name, then javascript on FacebookJSBridge.as looks for an element with the identifier null.

Or, if you specify a name but not id, then javascript on FacebookJSBridge.as looks for a suitable string, but there is an element without such an identifier.

If you specify the name AND an identical identifier, then he can really find swf.


 var appId = "1234567890"; var swfNameAndId = "app_" + appId; swfobject.embedSWF("/swfs/TestApp.swf", "app_placeholder", 760, 450, "9.0.0", false, { "appId": appId }, { "allowscriptaccess": "always" }, { "name": swfNameAndId, "id": swfNameAndId }); 
0
source

Replace

 embedSWF("MyApp.swf", "flashContent", "640", "480", "9.0", null, null, null, {name:"flashContent"}); 

with

 swfobject.embedSWF("MyApp.swf", "flashContent", "640", "480", "9.0", null, null, null, {name:"flashContent"}); 

i.e. swfobject. embedSwf

Worked like a charm!

0
source

In my case, it was index.template.html, which did not work. I needed: 1) a link to the SDK FB JS
2) use fb-root div as the first entry inside the body tag

who solved my problem.

Edit: I was confused that the Facebook.init () function only works when a user logs in. For authentication, I call Facebook.login

Edit2: Repeat this thing ... This time I missed that the URL of the canvas should point to your page, unless, of course, the call goes to another page and you never get an answer. Obviously, but he hit me again ...

0
source

All Articles