Last active
March 4, 2016 19:17
-
-
Save marcolink/c627c6f965cbdbba88d1 to your computer and use it in GitHub Desktop.
Image Flash to Facebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
post image to facebook wall