从Flash应用访问Facebook相册

时间:2010-11-12 03:17:57

标签: facebook flash-cs5

我想创建一个Flash应用程序,在按下按钮后,用户将能够浏览他/她的相册并选择一张照片。我该怎么做?按钮下的代码是什么,以获得使用此应用程序的任何用户的身份验证? 感谢。

1 个答案:

答案 0 :(得分:1)

我目前正在为大学作业编写一个facebook应用程序,允许用户在Facebook上做所有事情,但是通过Flash播放器窗口。为了做到这一点,你需要做一些基本的事情。

  1. 用户登录和身份验证 - 这必须通过Facebook完成 - 使用OAuth身份验证,并满足所有Facebook的安全策略
  2. 在facebook上注册申请
  3. 使用Graph API(facebook的开发人员工具包)获取将通过flash与facebook通信的必要功能。
  4. 在Flash本身,你将使用一堆URLRequest函数发送给FB获取信息,然后你需要检索那些数据响应并将它们存储到变量中(用几行代码提取数据很容易,类似于这;

    //initialise variables
    
    public var photoURL:String;
    
    var Request:URLRequest = new URLRequest("http://www.whatever the url  for the graph api service you are using which is founf from FB");
    
    //that ^^ will send off a request for the url, you then want to use the returned data by registering an event handler like this below
    
    functionName.addEventListener(onComplete, completeHandler);
    
    functionName(event, EVENT)
    {
       var loader:URLLoader = new URLLoader(Request);
       var data:XML = new XMLData(load.loader); //i think this is right but not 100% sure, fiddle with it
       //then you want to extract the data that is returned, for example, extracting xml data from a rest request works by hitting data from the xml by specifying a path to the object you want. an example of xml is this <rsp stat="ok"><photos ......more code="morecode"><photo url="url of photo"></photo</photos> so you can hit the url in that example like this;
    
       photoURL = data.photos.photo.@url; //this line will grab the photo url for you, allowing you to dynamically create an array and assign photos to the flash stage according to the url you get
    }
    

    这是相当高级的东西,我假设您对AS3,XML和FB API有一定的了解,如果您需要更多帮助,请回复