如何发布自己的Facebook页面
问题描述:
我要发布的图像作为我的网页(例如风扇页)如何发布自己的Facebook页面
我用这上,但它与网页网友发帖后,但我想为我的页面发布。
GraphRequest request = GraphRequest.newPostRequest(accessToken, "Page_ID"+"/photos"
, null, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
if(response.getError()==null) {
Toast.makeText(FacebookShareActivity.this, "Shared on facebook page.", Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(FacebookShareActivity.this, "Error while sharing on facebook page.", Toast.LENGTH_LONG).show();
}
}
});
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
Bundle params = request.getParameters();
params.putByteArray("object_attachment",byteArray);
params.putString("description", "Image");
request.setParameters(params);
request.executeAsync();
答
你必须使用的,而不是用户令牌页面令牌,你可以在文档阅读:https://developers.facebook.com/docs/graph-api/reference/page/feed#publish
关于令牌和如何A page access token with publish_pages permission can be used to publish new posts on behalf of that page. Posts will appear in the voice of the page.
更多的信息来生成它们:
thanku先生我用这个和响应 {响应:responseCode:400,graphObject:空,错误:{HttpStatus:400,errorCode:100,errorType:OAuthException,errorMessage:(#100)参数object_attachment:无效的id:{ }}} –
如何获得页面令牌? –
我已经在我的回答中添加了一些链接 – luschn