Skip to content

Instantly share code, notes, and snippets.

@marcolink
Last active March 4, 2016 19:17
Show Gist options
  • Save marcolink/c627c6f965cbdbba88d1 to your computer and use it in GitHub Desktop.
Save marcolink/c627c6f965cbdbba88d1 to your computer and use it in GitHub Desktop.
Image Flash to Facebook
post_image_to_facebook: function(d, f) {
var flashData = f[0];
var bs = window.atob( flashData.image ); // data from flash without mime type and base64 identifier
var ia = new Uint8Array(bs.length);
for (var i = 0, a = bs.length; i < a; i++) {
ia[i] = bs.charCodeAt(i);
};
var blob = new Blob([ia], { type:"image/jpeg" });
var fd = new FormData();
fd.append("access_token", window.g9_config.access_token);
fd.append("image", blob);
fd.append("fileName", flashData.fileName);
$.ajax({
url:"https://graph.facebook.com/me/photos",
type:"POST",
data:fd,
processData:false,
contentType:false,
cache:false,
success:function(data){
console.log("success");
},
error:function(shr,status,data){
console.log("error " + data + " Status " + shr.status);
},
complete:function(){
// flash complete callback
console.log("complete");
}
});
},
@marcolink
Copy link
Author

post image to facebook wall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment