简体   繁体   中英

Facebook post custom action to timeline

I have created a custom action that I want to allow users to post to their timeline with eg {User} read {Article}. I can get this to work fine when I do a post using the sample URL like this :

    FB.api('/me/fbsite:actionname' + 
'?object=http://samples.ogp.me/356694057772404&access_token=abc','post'

But when I replace the sample URL with my own URL I get the error 'The session was invalidated explicitly using an API call'. Can anybody please advise?

EDIT : Changed my Javascript to this, but I now get 'Invalid OAuth Access Token' :

<script type="text/javascript">
function redeem() {
    FB.api('/me/fbsite:actionname' +
   '?object=http://samples.ogp.me/356694057772404&access_token=\' + <%=UserManager.Current.FB.accessToken %>  + \'', 'post',
   function (response) {
       var msg = 'Error occured';
       if (!response || response.error) {
           if (response.error) {
               msg += "\n\nType: " + response.error.type + "\n\nMessage: " + response.error.message;
           }
           alert(msg);
       }
       else {
           alert('Post was successful! Action ID: ' + response.id);
       }
   });
}

That might be because you are using the same access token in same session. So try logging out and log back in, get a new FB access token, and try the query using the new access token you got, that should work as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM