1

I am trying to post comment on wall using following code after successful login.

    public void postOnWall(String msg) {
        Log.d("Tests", "Testing graph API wall post");
        //byte[] by_new = msg.getBytes();
         try {
                String response = mFacebook.request("me");
                Bundle parameters = new Bundle();
                parameters.putString("message", msg);
                parameters.putString("description", "test test test");
                response = mFacebook.request("me/feed", parameters, 
                        "GET");
                Log.d("Tests", "got response: " + response);
                if (response == null || response.equals("") || 
                        response.equals("false")) {
                   Log.v("Error", "Blank response");
               }
         } catch(Exception e) {
             e.printStackTrace();
         }
    }

Logcat:

06-01 17:51:44.042: DEBUG/Tests(623): got response: {"data":[]}

But when I used GET method I received blank response and when I used POST method I received following response.

06-01 18:04:26.522: WARN/Bundle(676): Key message expected byte[] but value was a java.lang.String.  The default value <null> was returned.
06-01 18:04:26.532: WARN/Bundle(676): Attempt to cast generated internal exception:
06-01 18:04:26.532: WARN/Bundle(676): java.lang.ClassCastException: java.lang.String
06-01 18:04:26.532: WARN/Bundle(676):     at android.os.Bundle.getByteArray(Bundle.java:1305)
06-01 18:04:26.532: WARN/Bundle(676):     at com.facebook.android.Util.openUrl(Util.java:156)
06-01 18:04:26.532: WARN/Bundle(676):     at com.facebook.android.Facebook.request(Facebook.java:559)
06-01 18:04:26.532: WARN/Bundle(676):     at com.kmiller.facebookintegration.Login.postOnWall(Login.java:108)
06-01 18:04:26.532: WARN/Bundle(676):     at com.kmiller.facebookintegration.Login$1.onClick(Login.java:78)
06-01 18:04:26.532: WARN/Bundle(676):     at android.view.View.performClick(View.java:2485)
06-01 18:04:26.532: WARN/Bundle(676):     at android.view.View$PerformClick.run(View.java:9080)
06-01 18:04:26.532: WARN/Bundle(676):     at android.os.Handler.handleCallback(Handler.java:587)
06-01 18:04:26.532: WARN/Bundle(676):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-01 18:04:26.532: WARN/Bundle(676):     at android.os.Looper.loop(Looper.java:123)
06-01 18:04:26.532: WARN/Bundle(676):     at android.app.ActivityThread.main(ActivityThread.java:3647)
06-01 18:04:26.532: WARN/Bundle(676):     at java.lang.reflect.Method.invokeNative(Native Method)
06-01 18:04:26.532: WARN/Bundle(676):     at java.lang.reflect.Method.invoke(Method.java:507)
06-01 18:04:26.532: WARN/Bundle(676):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-01 18:04:26.532: WARN/Bundle(676):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-01 18:04:26.532: WARN/Bundle(676):     at dalvik.system.NativeStart.main(Native Method)
Krishnakant Dalal
  • 3,568
  • 7
  • 34
  • 62
  • 1
    http://stackoverflow.com/questions/3726429/post-message-to-facebook-wall-from-android-fb-sdk-always-error/3927541#3927541 – Akram Jun 01 '12 at 05:46
  • comment on this line String response = mFacebook.request("me"); and than check it as i have answered – Khan Jun 01 '12 at 05:57
  • @Akki Thanks but now Response : 06-01 18:33:46.452: DEBUG/Tests(843): got response: {"error":{"message":"(#200) The user hasn't authorized the application to perform this action","type":"OAuthException","code":200}} – Krishnakant Dalal Jun 01 '12 at 06:02
  • ofcourse it wud be if user is not authorized make sure user is logged in and session is valid. – Akram Jun 01 '12 at 08:12

1 Answers1

1

try this i think as u have put "GET" instead of "POST"

String response = facebook.request("me/feed", parameters,"POST");
Khan
  • 7,585
  • 3
  • 27
  • 44