【问题标题】:sharing image with description in facebook在 facebook 中分享带有描述的图片
【发布时间】:2014-03-13 18:20:58
【问题描述】:

我想在 facebook 上与 Message 分享图像,我尝试了下面的代码,但它只会发布状态更新之类的消息。 将图像作为字节数组传递。

            String response = facebook.request("me");
        Bundle parameters = new Bundle();

        Bitmap bitmap = BitmapFactory.decodeResource(Radio.this.getResources(), R.drawable.ic_launcher);
        byte[] data = null;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        data = baos.toByteArray();

        parameters.putByteArray("picture", data);
        parameters.putString("message", msg);
        parameters.putString("description", "test test test");

        // parameters.putByteArray("message", );
        response = facebook.request("me/feed", parameters, "POST");
        Log.d("Tests", "got response: " + response);
        Toast.makeText(getApplicationContext(), "Successful Shared", Toast.LENGTH_SHORT).show();

【问题讨论】:

    标签: android facebook


    【解决方案1】:

    我得到了解决方案,只需用此代码替换即可。

            try {
            String response = facebook.request("me");
            Bundle parameters = new Bundle();
            Bitmap bitmap = BitmapFactory.decodeResource(Radio.this.getResources(), R.drawable.osho_shre_fb_t);
            byte[] data;
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
            data = baos.toByteArray();
    
            // parameters.putString("picture",
            // "http://www.digitaltrends.com/wp-content/uploads/2013/04/Samsung-Galaxy-6-3-sample-image-3.jpg");
    
            parameters.putString("message", msg);
    
            parameters.putString("description", "test test test");
            // Bundle parameters1 = new Bundle();
            parameters.putByteArray("picture", data);
            response = facebook.request("me/photos/feed", parameters, "POST");
    

    【讨论】:

      【解决方案2】:

      您不能使用 Intent 共享描述,您必须使用 Facebook API 与图像一起共享描述。

      【讨论】:

        【解决方案3】:

        不能直接上传图片到

        POST /me/feed
        

        端点,请参阅此处的文档 (https://developers.facebook.com/docs/graph-api/reference/user/feed/#publish) 或现有答案

        你能做的是

        1) 通过

        上传图片
        POST /me/photos
        

        2) 并将生成的照片 ID 用作提要端点的“object_attachment”字段的输入值

        【讨论】:

        • 你能提供代码吗?我已将 POST /me/ 替换为 POST /me/photos 但它只会发布状态而不是图像。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-13
        • 1970-01-01
        • 2019-12-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多