批准Android应用程序的Facebook照片

时间:2013-03-06 03:49:20

标签: android facebook

我的目标是将图片从Android应用程序发布到用户的脸谱墙而不要求他批准。

我使用以下代码发布图片:

String comment = editText.getText().toString();

byte[] data;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();

Bundle postParams = new Bundle();
postParams.putString("message", comment);
postParams.putByteArray("picture", data);

Request.Callback callback = new Request.Callback() {
    public void onCompleted(Response response) {

        FacebookRequestError error = response.getError();
        if (error != null) {
            Toast.makeText(SendActivity.this, "Facebook post error.",
                    Toast.LENGTH_SHORT).show();
            Log.e(TAG, error.toString());
        } else {
            Toast.makeText(SendActivity.this, "Posted to facebook!",
                    Toast.LENGTH_LONG).show();
        }
    }
};

Request request = new Request(session, "me/photos", postParams,
        HttpMethod.POST, callback);

RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();

在Facebook应用设置中,我添加了两个权限:user_photos和publish_actions。 该应用未处于沙盒模式。

当我使用应用程序上传图片时,它会转到与我的应用名称相同的相册,并且有一个标签是这些照片是从应用上传的,因此我需要批准或拒绝它。 如何在没有“审批”阶段的情况下发布图片?

1 个答案:

答案 0 :(得分:0)

我认为你需要publish_stream权限(而不是publish_action)。

请参阅https://developers.facebook.com/docs/reference/api/user/#photos