0

在桌面上的facebook應用程序上傳照片後,我需要將其發佈ID存儲在數據庫中。從facebook的ActionScript中SDK文檔:如何使用Facebook-Actionscript SDK獲取Facebook的發帖ID?

API()方法

public static function api(method:String, callback:Function, params:* = null, requestMethod:String = GET):void 

使在Facebook上的圖形API的新請求。

參數[...]

callback:Function — Method that will be called when this request is complete The handler must have the signature of callback(result:Object, fail:Object); On success, result will be the object data returned from Facebook. On fail, result will be null and fail will contain information about the error. 

所以我實現我的回調函數如下:

protected function handleUploadComplete(response:Object, fail:Object):void{ 

      status = (response) ? 'Success' : 'Error'; 
      var file:File = File.desktopDirectory.resolvePath("Log.txt"); 
      var stream:FileStream = new FileStream(); 
      stream.open(file, FileMode.WRITE); 
      stream.writeUTFBytes(response.toString()); 
      stream.close(); 

     } 

的問題是,響應或response.toString()都返回「[對象的對象]「,我希望能有更像」id:somenumber「的東西。 我在做什麼錯?

回答

1

如果一切正常,response將包含名爲id的屬性,它是您的帖子ID。否則它將爲空,並且fail對象將被填充。

protected function handleUploadComplete(response:Object, fail:Object):void 
{ 
    var status:Boolean = response != null; 
    if(status) var id:String = response.id; 
    //do whatever you want 
} 
相關問題