简体   繁体   English

Facebook SDK发布照片赞

[英]Facebook SDK post photo likes

I try to post a photo like on behalf of the current user. 我尝试代表当前用户发布照片。 But i get #200 Permission Error. 但我收到#200权限错误。 What i am doing wrong? 我做错了什么? Need i other permissions? 需要其他权限吗? I tried also with all permissions, still no luck. 我也尝试了所有权限,但还是没有运气。

require_once 'facebook-php-sdk/src/facebook.php';

class photo_liker {
function __construct()
{
    $this->facebook = new Facebook( array('appId' => fb_appID, 'secret' => fb_secret, 'fileUpload' => true, 'cookie' => true));
}

function postPhotoLike($photoid)
{
    try {
        $args = array('access_token' => $this->facebook->getAccessToken());
        $upload_photo = $this->facebook->api('/' . $photoid . '/likes', 'post', $args);
    } catch (FacebookApiException $e) {
        var_dump($e);
    }

}

function login()
{
    try {
        $uid = $this->facebook->getUser();
    } catch (Exception $e) {
        var_dump($e);
    }

    if($uid) {
        try {
            $user = $this->facebook->api('/me');
        } catch (Exception $e) {
            var_dump($e);
        }

        return true;
    } else {
        $login_url = $this->facebook->getLoginUrl(array('scope' => 'email,publish_stream'));

        ob_clean();
        echo("<script>top.location.href='" . $login_url . "'</script>");
        exit ;
    }
    return false;
}

 }

$test = new photo_liker();
$test->login();
$test->postPhotoLike('10150758570710223');

Ok it was because the test users from Facebook dev had not liked the page on with the photo was posted. 好的,是因为Facebook开发人员的测试用户不喜欢张贴带有照片的页面。 If they like the page all goes right. 如果他们喜欢该页面,则一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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