1

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

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;


?>

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

4

0 回答 0