0

I tried this example : Android how to post picture to friend's wall with facebook android sdk

but not work. here is my code :

String response = Utility.mFacebook.request((userID == null) ? "me" : userID);

            final Bundle params = new Bundle();
            params.putString("message", "test");
            params.putString("caption", "test");
            params.putString("picture", "http://www.facebook.com/images/devsite/iphone_connect_btn.jpg");

            response = Utility.mFacebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST");

Any sample code that able post video/photo on friend wall?

Community
  • 1
  • 1
sarak
  • 91
  • 10

1 Answers1

0

This is the method i use to post a picture to a wall, it posts a pic from a URL but you can change it to put a byte[] for the pic instead. The message appears above the picture and the caption appears to the right of the picture.

protected void postPicToWall(String userID, String msg, String caption, String picURL){
    try {
        if (isSession()) {
            String response = mFacebook.request((userID == null) ? "me" : userID);

        Bundle params = new Bundle();
        params.putString("message", msg);  
        params.putString("caption", caption);
        params.putString("picture", picURL);

        response = mFacebook.request(((userID == null) ? "me" : userID) + "/feed", params, "POST");       

        Log.d("Tests",response);
        if (response == null || response.equals("") || 
                response.equals("false")) {
            Log.v("Error", "Blank response");
        }
    } else {
        // no logged in, so relogin
        Log.d(TAG, "sessionNOTValid, relogin");
        mFacebook.authorize(this, PERMS, new LoginDialogListener());
    }
}catch(Exception e){
    e.printStackTrace();
    }
}

To post a byte[] rather than a url to a pic then replace the line

params.putString("picture", picURL); with

params.putByteArray("picture", getIntent().getExtras().getByteArray("data"));

where data is your array.

blganesh101
  • 3,647
  • 1
  • 24
  • 44