如何使用facebookapi的publish_action权限
How to use publish_action permission of facebook api?
我想在facebook中发布base64编码的图像。下面是我的代码
function postImageToFacebook(authToken, filename, mimeType, imageData, message) {
// this is the multipart/form-data boundary we'll use
var boundary = '----ThisIsTheBoundary1234567890';
// let's encode our image file, which is contained in the var
var formData = '--' + boundary + ''r'n'
formData += 'Content-Disposition: form-data; name="source"; filename="' + filename + '"'r'n';
formData += 'Content-Type: ' + mimeType + ''r'n'r'n';
for (var i = 0; i < imageData.length; ++i) {
formData += String.fromCharCode(imageData[i] & 0xff);
}
formData += ''r'n';
formData += '--' + boundary + ''r'n';
formData += 'Content-Disposition: form-data; name="message"'r'n'r'n';
formData += message + ''r'n'
formData += '--' + boundary + '--'r'n';
var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://graph.facebook.com/me/photos?access_token=' + authToken, true);
xhr.onload = xhr.onerror = function () {
console.log(xhr.responseText);
};
xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
if(!xhr.sendAsBinary){
xhr.sendAsBinary = function(datastr) {
function byteValue(x) {
return x.charCodeAt(0) & 0xff;
}
var ords = Array.prototype.map.call(datastr, byteValue);
var ui8a = new Uint8Array(ords);
this.send(ui8a.buffer);
}
}
xhr.sendAsBinary(formData);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
alert('Your image has been successfully shared');
}
}
};
var data = yourDesigner.getProductDataURL();
var encodedPng = data.substring(data.indexOf(',') + 1, data.length);
var decodedPng = Base64Binary.decode(encodedPng);
// var decodedPng = dataURItoBlob(test,"png");
FB.getLoginStatus(function (response) {
var request = {};
if (response.status === "connected") {
request = postImageToFacebook(response.authResponse.accessToken, "test", "image/png", decodedPng, "www.captivations.com.au");
} else if (response.status === "not_authorized") {
FB.login(function (response) {
request = postImageToFacebook(response.authResponse.accessToken, "test", "image/png", decodedPng, "www.captivations.com.au");
}, {scope: "publish_actions"});
} else {
FB.login(function (response) {
request = postImageToFacebook(response.authResponse.accessToken, "test", "image/png", decodedPng, "www.captivations.com.au");
}, {scope: "publish_actions"});
}
});
我可以在登录我的facebook帐户时发布图片。但当我试图发布来自其他帐户的图像时,我得到了以下错误
"错误":{"message":"(#200)需要扩展权限:publish_actions","type":"OAuthException","代码":200,"fbtrace_id":"EAcb5VG/eFS"}
我认为这是facbookapi的许可问题。你能帮我管理facebook的"发布操作"权限吗?
来源https://developers.facebook.com/docs/facebook-login/permissions:
";publish_actions"提供了代表使用您的应用程序的人发布帖子、Open Graph操作、成就、分数和其他活动的访问权限。
您的应用程序无需请求publish_actions权限即可使用Feed对话框、request对话框或Send对话框。
如果使用";publish_actions"你必须以另一种方式请求Facebook审查你的应用程序如何使用";publish_actions"准许
相关文章:
- 在流星上使用微信js-sdk时出现拒绝权限错误
- 从选项页面更新chrome扩展清单权限
- 从应用程序脚本检查谷歌网站访问权限
- 在Nodejs中Express输入DEBUG=app时权限被拒绝/bin
- 如何使用Javascript客户端对象模型检索Sharepoint 2010列表项权限
- 如何将权限/授权数据传递到客户端Javascript
- 根据HTML文件名授予web服务器写入权限
- 如何在javascript清单中获取地理位置权限
- 表单's的action属性-如何在javascript中指定完整的应用程序路径
- 如何在My chrome扩展中获取其他chrome扩展的DOM访问权限
- 调用laravel{{action(Controller@method}}通过传递vue.js数组中的变量
- 如何在标志中检查权限
- 从另一个JSAppleScript运行另一个JS AppleScript时出现权限错误
- 为什么在中声明具有外部访问权限的变量
- webkitspeechrecognition不再提示获得权限
- AWS Lambda上的权限问题,可以't派生子进程
- 使用对数据库的写入权限保护文件
- 活动在magento中记录用户角色和权限
- 带有Cordova的iPhone上的位置权限警报
- 您没有权限调用msgbox