0

i just wanna post a text message into my friend's facebook wall from my android application.Here i list out my friend's list & got particular friend Id to whom i need to send.But i couldn't able to send the message to tht particular friend.Below is my code.

        facebook = new Facebook("My App Id");
        asyncRunner = new AsyncFacebookRunner(facebook);
        FaceBook.facebook.authorize(this, new String[] { "user_status", "user_about_me", "email", "publish_stream", "read_stream", "offline_access" }, new DialogListener() {

            @Override
            public void onComplete(Bundle values) {

                JSONObject jObject;
                try {
                    jObject = new JSONObject(FaceBook.facebook.request("me"));
                    Bundle params = new Bundle();
                    params.putString("message", "My message");
                    params.putString("target_id","My friend fb Id here"); 
                    params.putString("method", "stream.publish");

                    //String  response = authenticatedFacebook.request(params);
                    FaceBook.asyncRunner.request("me/feed", params, "POST",
                            new ProductUploadListener(), null);
                    Toast.makeText(getApplicationContext(), "Successfully post..", Toast.LENGTH_SHORT).show();

                } catch (MalformedURLException e) {

                    e.printStackTrace();
                } catch (JSONException e) {

                    e.printStackTrace();
                } catch (IOException e) {

                    e.printStackTrace();
                }
            }

            @Override
            public void onFacebookError(FacebookError error) {
                Toast.makeText(fbFriendsList.this,
                        "Facebook onFacebookError", Toast.LENGTH_LONG).show();
            }

            @Override
            public void onError(DialogError e) {
                Toast.makeText(fbFriendsList.this, "Facebook onError",
                        Toast.LENGTH_LONG).show();
            }

            @Override
            public void onCancel() {

            }
        });


    }
    public class ProductUploadListener extends BaseRequestListener {
        public void onComplete(final String response, final Object state) {



        }
    }

where i did mistake.I used android facebook SDK also.

Thanks.

Vipul
  • 27,808
  • 7
  • 60
  • 75
sanjay
  • 2,590
  • 17
  • 55
  • 88
  • http://stackoverflow.com/questions/5280720/facebook-post-on-friends-wall-in-android/7744153#7744153 – Venky Jun 15 '12 at 05:52
  • http://stackoverflow.com/questions/5217539/help-on-facebook-post-to-friends-in-android/8577141#8577141 – Venky Jun 15 '12 at 05:52

1 Answers1

0

Here you go

protected void postOnWall(String friendID)
{
    Bundle params = new Bundle();
    params.putString("message","put your message here");
    params.putString("caption", "put your caption here");
    params.putString("description", "Put your description here");
    params.putString("name", "put a name here");
    params.putString("picture", "URL of picture");
    params.putString("link", "If any link);        

    asyncRunner.request(((friendID == null) ? "me" : userId) + "/feed", params, "POST", new WallPostRequestListener(),null);       
}
Vipul
  • 27,808
  • 7
  • 60
  • 75
  • When i tried this sample, i got red line error on asncRunner.request as "The method request(String, Bundle, String, AsyncFacebookRunner.RequestListener, Object) in the type AsyncFacebookRunner is not applicable for the arguments (String, Bundle, String, WallPostRequestListener)" – sanjay Jun 15 '12 at 06:22
  • see updated answer puy null at the end and let me know if it is working? – Vipul Jun 15 '12 at 06:28