3

Following Facebook's Guide for the new open graph, I have managed to implement Timeline and "Read Article" Action on our WordPress-based site. But the guide makes you click a button to post the action. It might be silly question, but how do we make it automatically posting once user enters the article? Is that something that's happening AFTER the action has been approved by Facebook?

Does recommendation bar do that? Is that its purpose?

rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
Nikolaos Vassos
  • 246
  • 1
  • 13

3 Answers3

0

The Recommendation Bar is still in beta and won't work for anyone other than the App Administrators / Developers / Testers.

End-users will only get actions published once Facebook has approved the action. This usually takes a day or two if you provide adequate instructions. You will need to make sure users are able to remove their activity from within your site - this is a requirement for submitting a action:

Please make sure your users can

  1. Turn sharing on/off globally on each page an article appears.
  2. Remove articles they shared within your app on each page an article appears.
  3. Only generate read actions when you're sure someone is interested in reading the article.

For my WordPress site, I used some code like:

setTimeout( function() {
    FB.getLoginStatus(function(response) {
        if (response.status === 'connected') {
            //  publish action to facebook
            FB.api( '/me/{$action}', 'post', { article : '{$permalink}' } );
        } else if (response.status === 'not_authorized') {
            // the user is logged in to Facebook, 
            // but has not authenticated your app
        } else {
            // the user isn't logged in to Facebook.
        }
    });
}, 2000 );
Niraj Shah
  • 15,087
  • 3
  • 41
  • 60
0

Use some JavaScript to post the action after the page loads:

window.onload=postCook; 
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
John Oleynik
  • 594
  • 4
  • 19
0

Yes, the Recommendations Bar does this. You could implement something similar in your own code but the Recommendations Bar supports a bunch of things out of the box like sending the activity only once the user scrolls X% of the way down and/or after a specified time interval.

Using this markup the action should be tracked in 5 seconds after the bar has loaded:

<div class="fb-recommendations-bar" data-href="{YOUR URL}" data-read-time="5"></div>
Ben Regenspan
  • 10,058
  • 2
  • 33
  • 44