0

I would schedule a task to post on facebook's wall using spring social.

How can I do this?

ManuPK
  • 11,623
  • 10
  • 57
  • 76
  • Can you add more information about what you want? Do you want to make a post on behalf of a user, or a page? And do you want it to appear in the past or the future, or just appear instantly? – Connor Treacy Apr 30 '12 at 10:28
  • I would plan my posts (whether in my wall or in a page or group) by programming a message to a specific day and time – Jihed Jemai Apr 30 '12 at 12:43

2 Answers2

2

The Spring social sample on Github has some samples which will do the posting.

Here is the specific part of the code you need to use. I would assume that you might need to dig in a little before you can use this code.

public void postConnect(Connection<Facebook> connection, WebRequest request) {
        if (request.getAttribute(POST_TO_WALL_ATTRIBUTE, WebRequest.SCOPE_SESSION) != null) {
            try {
                connection.updateStatus("I've connected with the Spring Social Showcase!");
            } catch (ApiException e) {
                // Do nothing: No need to break down if the post-connect post can't be made.
            }
            request.removeAttribute(POST_TO_WALL_ATTRIBUTE, WebRequest.SCOPE_SESSION);
        }
    }

Now, since you have the posting part, You need to write a scheduler to call this method. Read here on how to write a Quartz scheduler using spring. Read here for the Spring API of the same.

ManuPK
  • 11,623
  • 10
  • 57
  • 76
  • This code allows to send a post immediately, what I want: add a calendar and schedule my post(programming a message to a specific day and time ), I saw that quartz spring allows the scheduling but I didn't know how toimplement it – Jihed Jemai Apr 30 '12 at 12:49
  • ok, you just need to integrate a scheduled job. I have updated my answer with that. – ManuPK Apr 30 '12 at 13:07
0

Actually now Facebook released this scheduling feature, so you don't need to be using some 3rd party application!

More on this :Facebook Brand Pages Update and Post Scheduling

vectorash
  • 11
  • 2
  • I notice the link is to your own blog. Would you like to add a link to official Facebook documentation? Preferably with an excerpt here, explaining how it works. Answers here on SO should not rely on external links, to prevent "link rot". – S.L. Barth is on codidact.com Oct 21 '12 at 16:15