【问题标题】:post drawable image to friend's wall is not posting on facebook in android将可绘制图像发布到朋友的墙上不会在 android 的 facebook 上发布
【发布时间】:2014-05-09 06:21:35
【问题描述】:

我正在尝试发布图片、消息、标题、链接。预计剩余的图片可以正常发布。 如果我提供图片的网址,它可以工作。但我想发送可绘制的图片。图片没有发布 我试过下面的代码:

class LoginDialogListener implements DialogListener {
    public void onComplete(Bundle values) {

        publishFeedDialog();

    }
    public void onFacebookError(FacebookError error) {
        showToast("Authentication with Facebook failed!");
        finish();
    }
    public void onError(DialogError error) {
        showToast("Authentication with Facebook failed!");
        finish();
    }
    public void onCancel() {
        showToast("Authentication with Facebook cancelled!");
        finish();
    }
}



private void publishFeedDialog() {
    final Bundle params = new Bundle();
  final Bitmap bit=BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bit.compress(CompressFormat.JPEG, 100, baos);
    byte[] data = baos.toByteArray();


    params.putString("to", Universal.ids);
    params.putString(Facebook.TOKEN, facebook.getAccessToken());
    params.putString("name", "Sending a birthday card!");
    params.putString("link", "https://play.google.com/store/search?q=dbgr&c=apps&hl=en");
     params.putString("description", "Wishing You a HAPPY BIRTHDAY");
     params.putString("picture", data);



    facebook.dialog(this, "feed", params, new DialogListener() {

        @Override
        public void onFacebookError(FacebookError e) {
            // TODO Auto-generated method stub
            showToast("Authentication with Facebook failed!");
            finish();
        }

        @Override
        public void onError(DialogError e) {
            // TODO Auto-generated method stub
            showToast("Authentication with Facebook failed!");
            finish();
        }

        @Override
        public void onComplete(Bundle values) {
            // TODO Auto-generated method stub
            showToast("Post is successfully sent");
            finish();
            Intent i=new Intent(getApplicationContext(),FrndActivity.class);
            startActivity(i);

        }

        @Override
        public void onCancel() {
            // TODO Auto-generated method stub
            showToast("Authentication with Facebook cancelled!");
            finish();
        }
    });

图片没有发布。请帮助我。

【问题讨论】:

    标签: android facebook-graph-api bitmap facebook-android-sdk android-facebook


    【解决方案1】:

    Feed 对话框的“图片”参数不支持上传位图,只支持 url。

    https://developers.facebook.com/docs/sharing/reference/feed-dialog/v2.0

    【讨论】:

    • 感谢您的回复。使用哪种方法从drawable发布位图。
    • 看看 FacebookDialog 类(它需要您使用新的 API,因为从您的代码来看,您似乎仍在使用旧的不推荐使用的获取访问令牌的方法)- developers.facebook.com/docs/reference/android/current/class/…里面有很多分享方式,都需要安装Facebook应用。
    • 感谢您的回复。我还有一个问题,我正在获取带有名称的朋友头像并设置为列表视图,但头像与名称不匹配。图片不正确
    • 查看我的问题的链接。个人资料图片与名称不匹配stackoverflow.com/questions/23466614/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-05
    • 1970-01-01
    • 2012-04-29
    相关资源
    最近更新 更多