3

How to post messages on my wall using restfb ?

I am using this code

    PostData(String accessToken) {
      facebookClient = new DefaultFacebookClient(accessToken);
 }
     void runMessage() {
            String messageId = publishMessage();
     }
 String publishMessage() {
    System.out.println("* Feed publishing *"); 
    FacebookType publishMessageResponse = facebookClient.publish("me/feed", FacebookType.class, Parameter.with("message", "RestFB test"),Parameter.with("link", "http://www.google.com"));
Sruthy Joseph
  • 69
  • 2
  • 7

2 Answers2

0

Your code works fine with me. Did you add publish_stream permission to you permissions?

More information see here.

Joel
  • 7,401
  • 4
  • 52
  • 58
0

This code works fine for me :

static final String MY_ACCESS_TOKEN;

static{MY_ACCESS_TOKEN  = 

/*

login to facebook then copy your access token from "https://developers.facebook.com/tools/explorer?method=GET&path=605545976%3Ffields%3Did%2Cname" and paste it here

*/}

//-------

FacebookClient facebookClient = new DefaultFacebookClient(MY_ACCESS_TOKEN);

void post(String message){
facebookClient.publish("me/feed",FacebookType.class,Parameter.with("message",message));
}
demongolem
  • 9,474
  • 36
  • 90
  • 105
Ahmed Adel Ismail
  • 2,168
  • 16
  • 23
  • i'm new to restFB my self, so i see no big difference between your code and mine ... maybe if you put your link as String in your message will work the same way ... i dont know !!! but what i'm sure of is that this code works fine and make sure your token didnt get expired as well – Ahmed Adel Ismail Apr 16 '13 at 13:33