OAuthException:无效的OAuth访问令牌签名

时间:2013-02-17 02:59:59

标签: php facebook facebook-graph-api curl

当我直接在浏览器中输入此网址时,我会将帖子发送到用户供稿墙

https://graph.facebook.com/xx facebook uid xx/feed?access_token=xx app access token xx&message=Welcome%20to%20App!&method=post

但是当我用这段代码自动化帖子时,它给了我这个错误OAuthException: Invalid OAuth access token signature.

<?PHP

    include_once "inc/facebook.php";
    require_once 'inc/config.php';

// Create our application instance
$facebook = new Facebook(array(
    'appId'     => $app_id,
    'secret'    => $app_secret,
    ));

$dbh = new PDO('mysql:dbname='.$db_name.';host='.$db_host.';charset=utf8', $db_username, $db_password );

$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$stmt = $dbh->prepare('SELECT fb_id FROM offline_access_users');

$stmt->execute();

$body = array(
            'message' => 'Test Multiple Messages', 
            'link'    => '',
            'picture' => '',
            'name'    => '',
            'description'=> ''
            );
    $batchPost=array();
    $i=1;       
    foreach ($stmt as $value) {
    $id = $value['fb_id'];

        $batchPost[] = array(
            'method' => 'POST',
            'relative_url' => "/" . $id . "/feed?access_token=" . $access_token,
            'body' => http_build_query($body) );    
        if($i++ == 50) {
            try {
                $multiPostResponse = $facebook->api('?batch=' . urlencode(json_encode($batchPost)), 'POST');
                echo "Success";
            } catch(FacebookApiException $e) {
                error_log($e);
                echo($e);
            }
            unset($batchPost);
            $i=1;
        }
    }

    if(isset($batchPost) && count($batchPost) > 0 ) {
        try{
            $multiPostResponse = $facebook->api('?batch=' . urlencode(json_encode($batchPost)), 'POST');
            echo "Success";
        } catch(FacebookApiException $e){
            error_log($e);
            echo($e);
        }
    }


$db = null;


?>

我真的不知道如何解决这个问题。请帮帮我

0 个答案:

没有答案