kverweij / facebook-actionscript-api

Automatically exported from code.google.com/p/facebook-actionscript-api
0 stars 0 forks source link

get picture of user causes result of type String instead of ByteArray #412

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. call to Facebook.api("/" + idUser + "/picture&", callback);
2. response from this call is type String and can't be converted into image

What is the expected output? What do you see instead?
response should be ByteArray

What version of the product are you using? On what operating system?
Graph API Web 1.8.1 sources

Please provide any additional information below.

I solved the problem with setting dataFormat to URLLoaderDataFormat.BINARY in 
urlLoader variable of function loadURLLoader in AbstractFacebookRequest class 
(by setting param variable in call to Facebook.api) 

protected function loadURLLoader():void {
    urlLoader = new URLLoader();
    if (urlRequest.data.dataFormat) urlLoader.dataFormat = urlRequest.data.dataFormat; //my fix

And also changed complete handler to properly handle image data (also in 
AbstractFacebookRequest.as):

protected function handleURLLoaderComplete(event:Event):void {
    if (urlLoader.dataFormat == URLLoaderDataFormat.BINARY) handleImageLoad(urlLoader.data)
    else handleDataLoad(urlLoader.data);
}

protected function handleImageLoad(result:Object): void {
    _success = true;
    _data = urlLoader.data;
    dispatchComplete();
}

my new call for get image is
Facebook.api("/" + idUser + "/picture&", callback, {dataFormat: 
URLLoaderDataFormat.BINARY});

Original issue reported on code.google.com by tlucz...@gmail.com on 13 Mar 2012 at 10:18