How to post on my wall using restfb
How do I post 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"));
+3
source to share
2 answers
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));
}
0
source to share