如何获得Facebook应用程序的publish_stream权限?

发布于 2024-12-09 10:00:58 字数 1314 浏览 0 评论 0原文

我有一个已经运行了一段时间的应用程序,它只请求一些帐户信息用于登录目的。现在我想用它发布到流。我已将publish_stream 添加到req_perms,但是它仍然不请求该权限。

我错过了什么吗?

<?php
# CREATE FACEBOOK BUTTON
    $facebook = new Facebook(array(
        'appId'  => FACEBOOKAPPID,
        'secret' => FACEBOOKSECRET,
        'cookie' => false,
    ));
    $fb_session = $facebook->getUser();
    $fb_me = null;
    // Session based API call.
    if ($fb_session) {
        try {
            $fb_uid = $fb_session;
            $fb_me = $facebook->api('/me');
            $fb_me['photo'] = 'http://graph.facebook.com/'.$fb_uid.'/picture?type=large';
            $_SESSION['login_api'] = 1;
            $_SESSION['login_api_details'] = $fb_me;
            $_SESSION['login_api_user_id'] = $fb_uid;

            # WE ARE GOOD TO GO, LETS GET THE ACCESS TOKEN
            $_SESSION['access_token'] = $facebook->getAccessToken();


            #header_redirect(SITEURL.'/login');         

        } catch (FacebookApiException $e) {
            error_log($e);
        }
    }
    else{
        # LOGIN URL FOR FACE BOOK & request extra stuff
        $fb_login_url = $facebook->getLoginUrl(array('req_perms'=>'publish_stream,email,user_about_me,user_birthday,user_website'));
        header_redirect($fb_login_url);
    }
?>

I have an app which has been running for a while which has only requested some account information for login purposes. Now I want to use it to publish to the stream. I have added publish_stream to the req_perms but, it still doesn't ask for that permission.

Am I missing something?

<?php
# CREATE FACEBOOK BUTTON
    $facebook = new Facebook(array(
        'appId'  => FACEBOOKAPPID,
        'secret' => FACEBOOKSECRET,
        'cookie' => false,
    ));
    $fb_session = $facebook->getUser();
    $fb_me = null;
    // Session based API call.
    if ($fb_session) {
        try {
            $fb_uid = $fb_session;
            $fb_me = $facebook->api('/me');
            $fb_me['photo'] = 'http://graph.facebook.com/'.$fb_uid.'/picture?type=large';
            $_SESSION['login_api'] = 1;
            $_SESSION['login_api_details'] = $fb_me;
            $_SESSION['login_api_user_id'] = $fb_uid;

            # WE ARE GOOD TO GO, LETS GET THE ACCESS TOKEN
            $_SESSION['access_token'] = $facebook->getAccessToken();


            #header_redirect(SITEURL.'/login');         

        } catch (FacebookApiException $e) {
            error_log($e);
        }
    }
    else{
        # LOGIN URL FOR FACE BOOK & request extra stuff
        $fb_login_url = $facebook->getLoginUrl(array('req_perms'=>'publish_stream,email,user_about_me,user_birthday,user_website'));
        header_redirect($fb_login_url);
    }
?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红衣飘飘貌似仙 2024-12-16 10:00:58

在你的其他地方试试这个

$params = array(
    'canvas' => 1,
    'scope'  => 'publish_stream,email,user_about_me,user_birthday,user_website',
    'fbconnect' => 1,
    'redirect_uri' => 'https://apps.facebook.com/YOURAPP',
);


$fb_login_url = $facebook->getLoginUrl($params);
header_redirect($fb_login_url);

Try this in your else

$params = array(
    'canvas' => 1,
    'scope'  => 'publish_stream,email,user_about_me,user_birthday,user_website',
    'fbconnect' => 1,
    'redirect_uri' => 'https://apps.facebook.com/YOURAPP',
);


$fb_login_url = $facebook->getLoginUrl($params);
header_redirect($fb_login_url);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文