Facebook的的Abobe AS3 API的空气流动空气、Abobe、Facebook、API

2023-09-08 12:07:55 作者:為你我鎖心、

我刨,涉及到跨平台(Android和iOS)的移动应用程序,登录使用Facebook的一个项目。我与脸书API没有经验,并不能找到任何使用用料十足的新手。我想用空气中的跨平台能力,所以要避免多种解决方案为每个平台。我已经做了很多搜索的帮助,但还没有找到太多。可以任你点我给你找到使用充满这样的事情出发资源。

I am planing a project that involves a cross platform (Android and I.O.S) mobile app that logs in using Facebook. I have no experience with the face book API and cant find any use full material for newbies. I want to use air for its cross platform capabilities so want to avoid multiple solutions for each platform. I have done many searches for help but haven't found much. Can any of you point me to resources you found use full starting off with this sort of thing.

推荐答案

在AS3 Facebook的API是你所需要的。 ( HTTP://$c$c.google.com/p/facebook -actionscript-API / )也许你将不得不改变一些东西(如JSON方法在那里),但除此之外,它似乎工作好了。你可以从那里下载几个例子还有,你可以看到使用不同类型的环境。

The AS3 Facebook API is all you need. ( http://code.google.com/p/facebook-actionscript-api/ ) Maybe you will have to change a few things (like the JSON methods in there) but otherwise it seems to work alright. You can download several examples from there as well, you can see the usage for different types of environment.

此外,阅读这篇文章从汤姆Krcha编写的http://www.adobe.com/devnet/games/articles/getting-started-with-facebooksdk-actionscript3.html

Also, read this article from Tom Krcha https://m.xsw88.com/allimgs/daicuo/20230908/635.pngEncoderOptions; import flash.display.Sprite; import flash.display.Stage; import flash.events.EventDispatcher; import flash.events.MouseEvent; import flash.geom.Rectangle; import flash.media.StageWebView; import flash.utils.ByteArray; import flash.utils.clearTimeout; import flash.utils.setTimeout; public class FacebookController extends EventDispatcher implements IDestroyable { private static const APP_ID:String = "1234512345"; // Your App ID. private static const SITE_URL:String = "some_url"; //Extended permission to access other parts of the user's profile that may be private, or if your application needs to publish content to Facebook on a user's behalf. private var _extendedPermissions:Array = ["publish_stream","user_website","user_status","user_about_me"]; private var _stage:Stage; private var _webView:StageWebView; private var _topStripe:WebViewCloseStripe; private var _activity:String; private var _timeoutID:uint; public static const ACTIVITY_LOGIN:String = "login"; public static const ACTIVITY_POST:String = "post"; public function FacebookController(stage:Stage) { _stage = stage; init(); } private function init():void { _activity = ACTIVITY_LOGIN; startTimeout(); FacebookMobile.init(APP_ID, onHandleInit, null); } private function onHandleInit(response:Object, fail:Object):void { if (response) { stopTimeout(); dispatchEvent(new FacebookControllerEvent(FacebookControllerEvent.LOGIN_COMPLETE)); //FacebookMobile.api("/me", handleUserInfo); } else { /*trace("no response, login -->"); for(var prop in fail["error"]) { trace(prop+": "+fail["error"][prop]); }*/ loginUser(); } } private function startTimeout():void { trace("timeout start"); clearTimeout(_timeoutID); _timeoutID = setTimeout(timeout, AppConst.TIMEOUT_TIME); } private function timeout():void { trace("timed out"); clearTimeout(_timeoutID); dispatchEvent(new FacebookControllerEvent(FacebookControllerEvent.TIMEOUT)); } private function stopTimeout():void { trace("timeout stop"); clearTimeout(_timeoutID); } private function loginUser():void { stopTimeout(); _topStripe = new WebViewCloseStripe(); _topStripe.getCloseButton().addEventListener(MouseEvent.CLICK, closeClickHandler); _stage.addChild(_topStripe); _webView = new StageWebView(); _webView.viewPort = new Rectangle(0, _topStripe.height, _stage.fullScreenWidth, _stage.fullScreenHeight - _topStripe.height); FacebookMobile.login(handleLogin, _stage, _extendedPermissions, _webView); } private function handleLogin(response:Object, fail:Object):void { if(_topStripe) { _topStripe.getCloseButton().removeEventListener(MouseEvent.CLICK, closeClickHandler); _topStripe.destroy(); _stage.removeChild(_topStripe); _topStripe = null; } if(_webView) { _webView = null; } if(response) { dispatchEvent(new FacebookControllerEvent(FacebookControllerEvent.LOGIN_COMPLETE)); //FacebookMobile.api('/me', handleUserInfo); } else { dispatchEvent(new FacebookControllerEvent(FacebookControllerEvent.LOGIN_ERROR)); } } private function closeClickHandler(e:MouseEvent):void { dispatchEvent(new FacebookControllerEvent(FacebookControllerEvent.CLOSE)); } private function handleUserInfo(response:Object, fail:Object):void { if (response) { for(var prop in response) { trace(prop+": "+response[prop]); } } } private function handleUploadImage(result:Object, fail:Object):void { stopTimeout(); if(result) { dispatchEvent(new FacebookControllerEvent(FacebookControllerEvent.POST_COMPLETE)); } else { dispatchEvent(new FacebookControllerEvent(FacebookControllerEvent.POST_ERROR)); } } public function postWithImage(message:String, imageData:BitmapData):void { _activity = ACTIVITY_POST; var byteArray:ByteArray = imageData.encode(new Rectangle(0, 0, imageData.width, imageData.height), new PNGEncoderOptions()); var params: Object = new Object; params.image = byteArray; params.fileName = "image.png"; params.message = message; startTimeout(); FacebookMobile.api("/me/photos", handleUploadImage, params, "POST"); } public function reset():void { FacebookMobile.logout(handleReset, SITE_URL); } public function handleReset(response:Object):void { dispatchEvent(new FacebookControllerEvent(FacebookControllerEvent.RESET)); } public function destroy():void { if(_webView) { _webView.dispose(); _webView = null; } if(_topStripe) { _topStripe.getCloseButton().removeEventListener(MouseEvent.CLICK, closeClickHandler); _topStripe.destroy(); _stage.removeChild(_topStripe); _topStripe = null; } _stage = null; } } }