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

后端 未结 3 1315
失恋的感觉
失恋的感觉 2020-12-11 13:01

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 ap

相关标签:
3条回答
  • 2020-12-11 13:43

    Post your code how you are uploading image to 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. 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 ; Hope might be helpful to you.

    0 讨论(0)
  • 2020-12-11 13:45

    a) How can i look for the "Wall Photos" album if the user's profile is in a different language?

    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.

    b) How can i create a "Wall Photos" album in case that it doesn't exists?

    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.

    0 讨论(0)
  • 2020-12-11 13:54

    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. thanks to user for sharing his answer, it really helps :D

    0 讨论(0)
提交回复
热议问题