0

I need to post a string on facebook timeline via facebook4j using java. But i am unable to send even a character. I have created an app on facebook for this issue. What i want is just to run a simple java program and that program should post the string on facebook. So that each of my friends should be able to see it as my status. This is my code:

public class FB_Stat_Updator {

    static String appID         = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    static String appSecretKey  = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    static String tok           = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX";


    public static void update_FB_Status(String appID, String appSecretKey) {
        Facebook fb = new FacebookFactory().getInstance();
        fb.setOAuthAppId(appID, appSecretKey);
        /*fb.setOAuthAccessToken(arg0);*/
        fb.setOAuthAccessToken(new facebook4j.auth.AccessToken(tok, null));
        try {
            fb.postStatusMessage("hello everyone");
        } catch (FacebookException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
    public static void main(String[] args) {
        FB_Stat_Updator.update_FB_Status(appID, appSecretKey);
    }
Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108
Anant666
  • 416
  • 9
  • 26
  • Right now i am facing the error: 'The user hasn't authorized the application to perform this action', errorCode=200' – Anant666 Jun 17 '15 at 04:13

1 Answers1

2

You need to get an access token for your application from here:

Click here :D

Do not forget to give your app the permissions. :D

Aditya Singh
  • 2,343
  • 1
  • 23
  • 42
  • Is this still possible? I am not able to post messages to my facebook wall using the same code given above. Can you please help me ? – Kutty Apr 13 '19 at 11:17