I try to tag multiple friends on the phot using the Graph API AS3 for my Flash application. If I’m using a value statically the result is success and works like a charm But when I try to feed the params.tags with a dynamic value I get from the array (populated from checkbox) it fails.
Here’s the dynamic and failed ones:
var arrUserID:Array = new Array("1447615481","1052646429");
var len:Number = arrUserID.length;
var someStr:String = "";
for (var i:Number=0;i<len;i++) {
someStr += arrUserID[i]+","+Math.round(Math.random()*imgHolder.width)+","+Math.round(Math.random()*imgHolder.height);
if(i != len-1){
someStr += "||";
}
}
var arr:Array = [];
arr = someStr.split("||");
var outputArr:Array = [];
var len2:Number = arr.length;
var temp:Array = [];
for (var j:Number=0;j<len2;j++) {
temp = arr[j].toString().split(",");
outputArr.push({'tag_uid':temp[0], 'x':temp[1], 'y':temp[2]});
}
var params:Object = new Object();
params.image = bitmap;
params.message = "YEZAAA";
params.fileName = "file-name";
**params.tags = JSON.encode(outputArr);** --> dynamic value from array
Facebook.api('me/photos', onSaveToPhotoAlbumComplete, params);
and here are the success version and the statical ones:
var params:Object = new Object();
params.image = bitmap;
params.message = "YEZAAA";
params.fileName = "file-name";
params.tags = '[{tag_uid:"12345678","x":"0","y":"0"},{tag_uid:"001 111","x":"0","y":"0"}]';
Facebook.api('me/photos', onSaveToPhotoAlbumComplete, params);
So it just keep me wondering, what is my wrong actually?
There is really a need here since I’ve been pulling my hair after a week try to figure out, but to no avail.
Here’s how I got my dynamic id’s to work with your code:
1) You have to remember that, like your static code, the tags parameter needs to ultimately result in a
String. Your dynamic version is using an actualObject. So keep it a String like so: