我正在尝试使用图形API将图片上传到Facebook。这就是我正在做的事情
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.test);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
largeIcon.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
Bundle bundle = new Bundle();
bundle.putByteArray("object_attachment", byteArray);// object attachment must be either byteArray or bitmap image
bundle.putString("message", "some message here");
bundle.putString("access_token", "my_access_token_for_page");
bundle.putBoolean("published", true);
GraphRequest graphRequest = new GraphRequest(AccessToken.getCurrentAccessToken(),
"{page_id}/photos",
bundle,
HttpMethod.POST,
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
Toast.makeText(MainActivity.this, "Completed", Toast.LENGTH_SHORT).show();
}
});
graphRequest.executeAsync();
但不幸的是我收到了这个错误
{Response: responseCode: 404, graphObject: null, error: {HttpStatus: 404, errorCode: 803, errorType: OAuthException, errorMessage: (#803) Some of the aliases you requested do not exist: {page_id}}}
我不知道什么是错的。 我使用GraphAPIExplorer生成了页面的访问令牌。
请帮我解决这个问题。 提前完成。