0

I want to send a message to my facebook page using my user credentials and using ngrok to make a localhost tunnel so that facebook can reach my machine. However I am still getting a bad request (500) telling me I havn't registered any domains or supdomains.

On developers.facebook.com I have something like this in my App domains: 04cda25e.ngrok.io

and I have this in my site Url https://04cda25e.ngrok.io/

This is my code:

//https://stackoverflow.com/questions/13376710/facebook-app-domain-name-when-using-localhost Ik krijg badrequest omdat ik geen appdomain opgegeven heb
    public void postToFacebook(){
        FacebookConnectionFactory connectionFactory =
                new FacebookConnectionFactory("1783242201976620", "******");

        OAuth2Operations oauthOperations = connectionFactory.getOAuthOperations();
        OAuth2Parameters params = new OAuth2Parameters();
        params.setRedirectUri("https://04cda25e.ngrok.io/1234");

//appid:1783242201976620 <<<<< not really an appid
//apptoken:Ycics4TEiCAs9JZXyHD4I489D6M <<<< this is like a mock apptoken. Totally not a real one that's for sure... 

        params.setScope("public_profile,email,user_birthday");

// upon receiving the callback from the provider: http://massapi.com/method/an/andExpect.html
        AccessGrant accessGrant = oauthOperations.exchangeCredentialsForAccess("*****", "****",params);
        Connection<Facebook> connection = connectionFactory.createConnection(accessGrant);
        Facebook facebook = connection.getApi();
        //facebook.pageOperations().
         facebook.feedOperations().updateStatus("I'm trying out Spring Social!");


    }

It throws the 500 error at the point where I'm trying to get the accessgrant.

Can someone please help?

EDIT: Heres a screenshot taken from my facebook settings: https://pasteboard.co/GXjfojs.png

Anyone have a clue on what I should change?

Maurice
  • 6,698
  • 9
  • 47
  • 104

1 Answers1

0

Well I haven't found a solution to my problem, but I have found a workaround that enables accessing a facebookpage without using Spring social to get an access grant. It goes like this:

1) login to facebookdeveloper

2) go to Tools & Support

3)Select Graph API explorer, with this you can request an access token manually.

4) press the get Token button and select the type you want

5) select the permissions you would like your app to have for that page and click 'Get Access Token

6)Facebook produces a String which is the Access token. Use this to instantiate an AccessGrant object in java by including this string in the AccessGrant constructor.

7) use this AccessGrant to create a connection and voila!

Hope this helps anyone..

Maurice
  • 6,698
  • 9
  • 47
  • 104