0
votes

//Update: With help I managed to catch some errors which fixed the token issue. I've updated the code to reflect that. The code still doesn't produce an event on the timeline though so I'm leaving the question up.

Original question:

I'm trying to build a simple script using the Open Graph API that will push a link to a visited page (containing a movie) to Facebook, once the visitor hits the page.

I'm not using a custom action and object, but the standard Watch action (https://developers.facebook.com/docs/opengraph/video/) and Video.movie object.

I came up with this based on FB's example code:

<!-- first login-button with scope publish_actions: -->
<fb:login-button show-faces="false" width="200" max-rows="1" scope="publish_actions"    ></fb:login-button>

<!-- Then script that should push update to timeline: -->
<script type="text/javascript">
    function fbPublish(){
        FB.api(
        '/me/video.watches',
        'post',
        { 'video.movie': '<?php the_permalink(); ?>',
        'access_token': 'blablabla'  },
        function(response) {
           if (!response || response.error) {
              alert('Nope.');
           } else {
              alert('Yes.'); // any stuff
           }
        });
    }

This triggers the alert 'Nope'.

I have added the Watch action through curl. Any ideas as to what could be going on?

1

1 Answers

0
votes

You still need to FB.login before you can automatically post to the user's timeline.

FB.login(function(response) {
      // Post the action
 }, {scope: 'publish_actions'});

While I didn't check the validity of your actual code to post the action, you problem is that before you can do this, you'll need the user's permission. The publish_actions permission is the one you'll need but I think its already included in new Auth Dialogs. Just leave it there to be sure.

Do the FB.login code first, you'll get a popup "Allow" dialog, after that, is the time you can freely post in the user's wall. It's a part of the security, Facebook users wouldnt want you posting on their timeline without them knowing.