Android how to send picture to friend in wall using facebook android sdk

We can publish a text message on a friend’s facebook wall, but how can we send an image, a picture to a friend’s wall using the Android Facebook SDK?

When I print the wall variable, it correctly shows USER_ID / feed. After the onComplete function is published, the RequestListener is called, but nothing has been sent to the friends wall.

Here is an example of the code we are trying to use:

Bundle params = new Bundle();
params.putString("method", "photos.upload");
params.putString("caption", photoCaption.getText().toString());
params.putByteArray("picture", data);

AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);

String wall = null;
wall = fArray.getJSONObject(pos).getString("id").toString() + "/feed";

mAsyncRunner.request(wall, params,"POST", new RequestListener(){

    public void onComplete(String response, Object state) {
        Log.d("text","facebook post complete");
    }

    public void onIOException(IOException e, Object state) {
        Log.d("text","facebook post onIOException");
    }

    public void onFileNotFoundException(FileNotFoundException e, Object state) {
        Log.d("text","facebook post onFileNotFoundException");
    }

    public void onMalformedURLException(MalformedURLException e, Object state) {
        Log.d("text","facebook post onMalformedURLException");
    }

    public void onFacebookError(FacebookError e, Object state) {
        Log.d("text","facebook post error");
    }

}, null);

This is how I get my friends list:

AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);

mAsyncRunner.request("me/friends", new RequestListener(){

    public void onComplete(String response,Object state) {
    try {
        jObject = new JSONObject(response);
        fArray = jObject.getJSONArray("data"); 
+2
source share
2 answers

, , URL-, , byte[] . , .

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();
    }
}

EDIT:

[], URL- ,

params.putString("picture", picURL);

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

.

+3

.

Bundle params = new Bundle();
        params.putString("message", "Test Post from karthick");
        params.putString("caption", "Karthick kumar");

        params.putString("name", "Hai Dude");
        **params.putString("icon", "http://www.facebook.com/images/icons/default_app_icon.gif");**
        params.putString("source", link);

... mAsyncRunner.request(, , "POST", RequestListener());

0

All Articles