duanpai9945
duanpai9945
2011-04-29 04:30
浏览 69
已采纳

Facebook错误验证访问令牌:会话已在unix时间到期

I have integrated the offline wall posting for the users of my website who have linked their FB accounts with there user details. I have stored there FB-id, FB-Access token in my database and by using the PHP-SDK libraries I had integrated the feed wall posting in the website. Everything worked very well with all users getting the messages on there facebook wall. But today all the things went in vain as it throws various kinds of error. I have been searching for more documents but can't find the exact relevant solution for this issues.

Lines of code i have used for FB-Wall Posting

             $usid=$pageinfo['user']['id_facebook'];
    $accestoken=$pageinfo['user']["facebook_accesstoken"];

        if($pageinfo['user']['user_fbtoken']=='1')

         $attachment =  array(
        'access_token' => $accestoken,
        'message' => "myTaste || real restaurant reviews, share your taste on myTaste",
        'name' => "My Favorite Restaurant is ".$business['name'].$business['location']['city']."-What is yours? ",
        'link' => $business['personal_url'],
        'description' => "", 
        'picture'=> "http://googima.com/images/mysite.gif"
        );  

        $facebook->api("/".$usid."/feed", "post",$attachment); 
    }

Error messages:

 Uncaught OAuthException: Error validating access token: Session has expired at unix time

 Uncaught OAuthException: (#210) User not visible thrown in /hsphere/local/home/mysite.com/include/3rdparty/facebook-php-sdk/src/facebook.php

The main idea of doing this offline wall posting is user is not going to asked for the FB login each time when do some reviews in the website. It need to post automatically by using the FB details that we have stored in the user table.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doujiu5464
    doujiu5464 2011-04-29 13:47
    已采纳

    Once you grant the publish_stream permission, no need for the access_token. So removing it and using something like this would work even without a valid session (just an example):

    $params =  array(
        'message' => "Test Message",
        'picture'=> "http://path/to/image.jpg"
    );  
    $post_id = $facebook->api("/$uid/feed", "post",$params);
    

    For more information refer to this answer (EDIT 4). Kudos to @zerkms for this info btw!

    点赞 评论
  • doujiekeyan0622
    doujiekeyan0622 2011-04-29 04:38

    Access token is not permanent in facebook oauth implementation. You need to renew it in the begin of your working session

    More details at: http://developers.facebook.com/docs/authentication/

    点赞 评论

相关推荐