-1

I can not find a working way to send a picture on the wall. My code is that I do not.

Bundle postParams = new Bundle();
    postParams.putByteArray("image", byteArray);
    postParams.putString("message", "A wall picture");

    Session session = Session.getActiveSession();
    if (session != null) {

        Log.e("Session", "don t null");
        Request request = new Request(session, "me/feed", postParams,
                HttpMethod.POST);
        RequestAsyncTask task = new RequestAsyncTask(request);
        task.execute();
Kara
  • 6,115
  • 16
  • 50
  • 57
  • This is done in OnCreate. Just having gone through this, I did authorize as in the example. And I got a username. But I can not send a picture. 'code' Session.openActiveSession(this, true, new Session.StatusCallback() {...} – Alex Poklad Aug 20 '13 at 13:46

1 Answers1

0

I've never sent pictures from the phone, but from a server using an image link. I'll put this code in case it helps you since most of the logic is similar.

final Bundle parameters = new Bundle();
parameters.putString("name", getString(R.string.app_name));
parameters.putString("caption", "haha");
parameters.putString("link", "www.google.com");
parameters.putByteArray("picture", byteArray);//I took this one from your code. My key is "picture" instead of "image"
Session.openActiveSession(this, true, new StatusCallback() {

    @Override
    public void call(Session session, SessionState state, Exception exception) {
        if (session.isOpened()) {
            new FeedDialogBuilder(EndGameActivity.this, session, parameters).build().show();

            //you can try this one instead of the one above if you want, but both work well
            //Request.newMeRequest(session, new Request.GraphUserCallback() {
            //
            //    @Override
            //    public void onCompleted(GraphUser user, Response response) {
            //        final Session session = Session.getActiveSession();
            //        new FeedDialogBuilder(EndGameActivity.this, session, parameters).build().show();
            //    }
            //}).executeAsync();
        }

    }
});

This code will only work in the last Facebook SDK 3.5 since Request.newMeRequest was recently introduced and should be used instead of Request.executeMeRequestAsync, which has been deprecated.

Also notice that the key I use is "picture" instead of "image". Maybe that's the problem with your code.

But I do it inside a onClick event when the user touch a button. Why do you need it in your onCreate method?

gian1200
  • 3,670
  • 2
  • 30
  • 59