0

데스크톱 페이 스북 응용 프로그램에 사진을 업로드 한 후에 해당 게시물 ID를 데이터베이스에 저장해야합니다. 페이스 북의 액션 SDK 설명서에서 :Facebook-Actionscript SDK로 Facebook 게시물 ID를 얻는 방법은 무엇입니까?

API() 메소드

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

는 페이스 북 그래프 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이라는 속성이 포함됩니다. 그렇지 않은 경우는 null이되어, 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 
} 
관련 문제