0
votes

When i'm uploading a image to facebook its giving a error

Fatal error: Uncaught OAuthException: (#200) Permissions error thrown in path_to_file/base_facebook.php on line 1325

Im using the facebook php sdk located here

https://github.com/facebook/facebook-php-sdk

This is my code

require 'facebook.php';


$facebook = new Facebook(array(
            'appId' => 'FB APP ID',
            'secret' => 'FB SECRET KEY',
        ));

// Get User ID
$user = $facebook->getUser();
if ($user) {

} else {
    $loginUrl = $facebook->getLoginUrl();
    header('Location:' . $loginUrl . '&scope=user_photos,publish_stream');
}

        if ($user) {
            if (isset($_GET['upload'])) {

                $facebook->setFileUploadSupport(true);
                $args = array('message' => ''.$site.'');
                copy(''.$fullurl.'', 'tmp/file.jpeg');
                $args['image'] = '@' . realpath('tmp/file.jpeg');
                $data = $facebook->api('/me/photos', 'post', $args);
                unlink('tmp/file.jpeg');
                //assigning users to tag and cordinates
                $argstag = array('to' => $user);
                $argstag['x'] = 40;
                $argstag['y'] = 40;
                $datatag = $facebook->api('/' . $data['id'] . '/tags', 'post', $argstag);

}

}

can anyone point me out why this error is occurring?

1

1 Answers

0
votes

See: https://developers.facebook.com/docs/facebook-login/permissions/v2.1

There is no such permission publish_stream anymore, v1.0 had it, but only for pages, not users.

publish_actions is what you want, change the scope to this and re-request permissions..