Skip to content Skip to sidebar Skip to footer

Android Post Picture To Facebook Public Page Wall

I'm currently able to post to a public page wall using: JSONObject json = new JSONObject(); json.put('message', 'I'm on your wall'); Request req = Request.newPostRequest(getSess

Solution 1:

This is my code to upload a photo stored locally on the phone:

Requestrequest6= Request.newUploadPhotoRequest(
                session,
                ((BitmapDrawable) getResources().getDrawable(
                        R.drawable.picture)).getBitmap(), callback6);
        RequestAsyncTasktask6=newRequestAsyncTask(request6);
        task6.execute();

This is to upload on your own wall. Reason why there is no option to choose another recipient is due to the breaking changes in February that will disable posting to other people's wall.

See my earlier answer.

EDIT:

what is the best way to upload a photo that will show up on a place's wall with a photo and message?

Can you try this and see if this works?

Bundleparameters=newBundle();
    parameters.putParcelable("picture", YOUR_BITMAP_HERE);
    parameters.putString("message", "my message for the page");

    returnnewRequest(session, "PowerCardSoftware/feed", parameters, HttpMethod.POST, callback);

Can I add a message using newUploadPhotoRequest()?

No, to add a message with your photo, you won't be using newUploadPhotoRequest. If you dig into the source, its just a wrapper of a Request, so do the same as the method, but add an additional parameter, message, with the message you want, and execute it. I haven't personally verified it but it should work. Let me know if it doesn't.

Solution 2:

This is my solution. I referenced Jesse Chen's answer and made some modifications.

Bitmapimage= BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "demo.jpg");
Bundleparameters=newBundle();
parameters.putParcelable("source", image);
parameters.putString("message", "my message for the page");
Requestrequest=newRequest(Session.getActiveSession(), "me/photos", parameters, HttpMethod.POST, newRequest.Callback() {
    @OverridepublicvoidonCompleted(Response response) {
        showPublishResult(mainActivity.getString(R.string.photo_post), response.getGraphObject(), response.getError());
    }
});
request.executeAsync();

Solution 3:

You can check facebookSDK project /tests folders and search keywords newPostRequest. the sample code is as below

GraphObjectstatusUpdate= GraphObject.Factory.create();
                Stringmessage="message";
                statusUpdate.setProperty("message", message);
                statusUpdate.setProperty("link", "http://stackoverflow.com/questions/14129546/android-post-picture-to-facebook-public-page-wall#");
            Requestrequest= Request.newPostRequest(Session.getActiveSession(), "me/feed", statusUpdate, newCallback() {

                @OverridepublicvoidonCompleted(Response response) {

                }
            });
            request.executeAsync();

Post a Comment for "Android Post Picture To Facebook Public Page Wall"