简体   繁体   English

Android facebook SDK,用不同语言的个人资料上传图片到墙上?

[英]Android facebook SDK, upload pictures to wall with profile in different language?

Currently I'm able to post mesages and pictures to my wall using my app, by looking for the album "Wall Photos" it works fine so far, i let a friend of mine to test my app on his phone to see if it works fine with any user, when he tried to upload a picture it didn't work, now i think it might be have something to do with the fact that his profile is in spanish, so looking for the album "Wall photos" could not be possible, i took a look at his photo albums and for my surprise he didn't have any "Wall photos" album equivalent in his language, So.. long story short: 目前我可以使用我的应用程序将消息和图片发布到我的墙上,通过查找专辑“Wall Photos”它到目前为止工作正常,我让我的一个朋友在他的手机上测试我的应用程序,看它是否有效对任何用户都很好,当他试图上传一张不起作用的图片时,现在我认为这可能与他的个人资料是西班牙语有关,所以寻找专辑“Wall photos”不可能可能,我看了他的相册,我惊讶地发现他没有任何“Wall photos”相当于他的语言,所以..长话短说:

a) How can i look for the "Wall Photos" album if the user's profile is in a different language? a)如果用户的个人资料使用其他语言,我如何查找“Wall Photos”专辑?

b) How can i create a "Wall Photos" album in case that it doesn't exists? b)如果不存在,我如何创建“Wall Photos”相册?

Any help is appreciated, thanks. 任何帮助表示赞赏,谢谢。

Post your code how you are uploading image to facebook. 发布您的代码如何将图像上传到Facebook。 And this is one sample code which is working fine for me just have a look might be helpful to you. 这是一个示例代码,对我来说工作正常只是看看可能对您有所帮助。 And in my code am not creating any album Wall Photos. 在我的代码中我没有创建任何专辑Wall Photos。 My picture gets uploaded in wall itself. 我的照片上传到墙上。 Just have a look ... 看看......

private void fbImageSubmit() {
    if (facebook != null) {
        if (facebook.isSessionValid()) {
            try {
                byte[] data = null;

                // Bitmap bi = BitmapFactory.decodeFile(Constants.imgShare);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();

                bmScreen.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                data = baos.toByteArray();

                Bundle parameters = new Bundle();
                parameters.putString("message", strmsg);
                parameters.putString("method", "photos.upload");
                parameters.putByteArray("picture", data);

                facebook.request(null, parameters, "POST");
                /*
                 * time = Calendar.getInstance().getTime().getHours() + ":"
                 * + Calendar.getInstance().getTime().getMinutes();
                 */

                currentTime = DateFormat.format("hh:mm", d.getTime());
                currentDate = DateFormat.format("dd/MM/yyyy", d.getTime());

                Cursor cursor = Constants.dbHelper
                        .GetDataFromImageName(Constants.enhancedImage
                                .getImagename());
                if (cursor.getCount() > 0) {
                    Constants.dbHelper.updateData(currentDate.toString(),
                            currentTime.toString(), "Facebook", "Image");
                } else {
                    Constants.dbHelper.insertData("true");
                }
                Toast.makeText(getApplicationContext(),
                        "Image uploaded successfully.", Toast.LENGTH_LONG)
                        .show();

            } catch (Exception e) {
                // TODO: handle exception
                System.out.println(e.getMessage());
            }
        }
    }
}

// bmscreen is my bitmap of image ; // bmscreen是我的图像位图; Hope might be helpful to you. 希望可能对你有所帮助。

try using 尝试使用

parameters.putString("caption", "ooo xxx");

instead of 代替

parameters.putString("message", "test post on wall");

should do the trick, it works to me :) 应该做的伎俩,它适用于我:)

ps. PS。 thanks to user for sharing his answer, it really helps :D 感谢用户分享他的答案,这确实有帮助:D

a) How can i look for the "Wall Photos" album if the user's profile is in a different language? a)如果用户的个人资料使用其他语言,我如何查找“Wall Photos”专辑?

Set the locale parameter to en_US while querying the Graph API for albums – then you'll get "Wall Photos" and not the localized album name. 在查询专辑的Graph API时将locale参数localeen_US - 然后您将获得“Wall Photos”而不是本地化的专辑名称。

b) How can i create a "Wall Photos" album in case that it doesn't exists? b)如果不存在,我如何创建“Wall Photos”相册?

Uh, I don't think creating it yourself would be a good idea, since normally it's automatically created by Facebook – so that might clash when FB later creates an album for the user's first actual wall posted photo. 呃,我不认为自己创建它会是一个好主意,因为通常它是由Facebook自动创建的 - 所以当FB稍后为用户的第一张实际壁挂照片创建一张专辑时可能会发生冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM