繁体   English   中英

Facebook 图 api 好友邀请函

[英]Facebook graph api Friend Invitations

我已经设法从 facebook 发送和检索数据,以便使用

FB.ui({
            method: 'apprequests',
            to: sendto,
            message: 'Win Mega Prizes!',
            title: 'Enter in this contest!'
        },
        function (response) {   
           if (response && response.request_ids) {
               var requests = response.request_ids.join(',');
               alert(requests);
                    window.location.href = "http://www.rmyserver/index.php?invitations="+requests+"&contest_id="+c_id+"&page_id="+page_id+"&user="+from+"&g_id="+g_id+"&sendto="+sendto+"&single=1";         

            } else {
                alert('canceled');
            }

PHP

foreach($requests as $request_id) {
        // Get the request details using Graph API
       echo $request_content = json_decode(file_get_contents("https://graph.facebook.com/$request_id?$app_token"), TRUE);

但我想使用单用户应用程序请求,根据文档我需要使用TO:提交,但这不起作用,请求也被发送,我得到邀请 ID,但上面使用的 php 代码返回 false。 我错过了什么吗

您可以尝试直接 url 此处给出的示例https://developers.facebook.com/docs/reference/dialogs/requests/#frictionless

从 php 应该可以正常工作

这对我有用:

FB.ui({
            method:'apprequests',
            message:'I want you to open up your heart a little.',
            to:123456798,
            // filters:['app_non_users'], // commented: let users send notifications to app users too, probably a good idea to make them revisit?
            data:'' // send data what you would like to track, FB will send that back in the URL for us
            // @todo send google campaign parameters
        });

此外,您在 PHP 方面做错了,您需要将用户重定向到 URL 将显示邀请朋友选择器。 据我所知,无法使用 PHP 直接向用户发送邀请。

暂无
暂无

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

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