javascript- facebook uploading photo -
i working on chrome extension project , i'm trying upload photo facebook album returns following response no matter image try upload.
{ "error": { "message": "this message contains content has been blocked our security systems.", "type": "oauthexception", "code": 368 } }
here code:
var canvas = document.createelement('canvas'); var ctx = canvas.getcontext('2d'); var img = new image; img.crossorigin = 'anonymous'; img.onload = function(){ canvas.height = img.height; canvas.width = img.width; ctx.drawimage(img,0,0); var dataurl = canvas.todataurl( 'image/png'); blob = datauritoblob(dataurl); goon(blob); canvas = null; }; img.src = "image url"; function datauritoblob(datauri) { var bytestring = atob(datauri.split(',')[1]); var ab = new arraybuffer(bytestring.length); var ia = new uint8array(ab); (var = 0; < bytestring.length; i++) { ia[i] = bytestring.charcodeat(i); } return new blob([ab], { type: 'image/png' }); } function goon(kkv){ var formdata= new formdata(); formdata.append("access_token", "acces token"); formdata.append("message", "test message"); formdata.append("source", kkv); formdata.append("privacy", "{'value':'everyone'}"); try { $.ajax({ url: 'https://graph.facebook.com/me/photos', type: "post", data: formdata, processdata: false, contenttype: false, cache: false, error: function (shr, status, data) { console.log("error " + data + " status " + shr.status); }, success: function (msg) { //successful } }); } catch (e) { console.log(e); } }
i using facebook graph api v2.3 access token( extended permissions)
i have tried use url parameter insted of source gave me same response
formdata.append("url", 'image url');
is there way without access token, wanna use facebook account on computer.if not, how can rid of error ?
no, need access token post facebook programatically. getting similar error , research seems indicate has frequency in post url. especially, if using , app , url's domain outside of app's domain. best answer either post less or use facebook's ad api, might run costs.