开发者

Facebook invite users to an app's page

I've got a Facebook app which I've added to a Facebook page. I want to allow a user to invite friends to go to the page with the app on and to interact with the app there.

I've can invite friends to the app like this:

FB.ui({ method: 'apprequests',
        message: '...'
     });

But I would actually like to invite them to the page that the app is on rather than the app itself.

I could allow users to send a message to friends instead using a link like: https://www.facebook.com/dialog/send?app_id=... which would allow me to include a link to my Facebook page, but wondered if there was a better wa开发者_Python百科y of doing so?

In particular I really like the apprequests ui which displays checkboxes for all your friends. Is there any way I can use this ui, but to promote the page rather than the app?


There is no official posibility to invite your friends directly to your page, since an app is unique but can be inserted in more than one page.

What you have to do is check in which context your app is been called. I don't know if you are using PHP for backend, but some server side code is neccessary.

You have to look for the signed_request Facebook is sending you, and if there is a page in it. Then save this context in the session.

If you are familiar with PHP, this may help you:

$signed_request = $fb->getSignedRequest();

if (isset($_REQUEST['signed_request'])){
    $context = (isset($signed_request['page'])) ? 'tab' : 'app';
    $_SESSION['fb_context'] = $context;
}
else {
    $context = isset($_SESSION['fb_context']) ? $_SESSION['fb_context'] : 'app';
}

If you find out that it is in app context you can redirect to the designated tab url.

if ($context == 'app') {
    header('Location: ...');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜