简体   繁体   English

如何允许用户使用“ apprequests”方法邀请朋友加入我的应用程序?

[英]How do I allow the user to invite friends to my app using the 'apprequests' method?

I am using the JavaScript SDK, and the documentation says that I can call a method that will create a dialog allowing the user to select and invite multiple friends to my app. 我正在使用JavaScript SDK,文档说明我可以调用一个方法,该方法将创建一个对话框,允许用户选择并邀请多个朋友加入我的应用程序。 Here is the code I am using: 这是我正在使用的代码:

FB.ui(
{
    method: 'apprequests',
    message: 'Invite your friends to use this app'
}, function(response)
{
    alert(response);
});

This code does not work. 此代码不起作用。 An error is produced when it is run: "Error: c is null" on line 18 of http://connect.facebook.net/en_US/all.js . 运行它时会产生错误: http://connect.facebook.net/zh_CN/all.js的第18行上的“错误:c为空”。 What am I doing wrong? 我究竟做错了什么?

This is what I use. 这就是我用的。 It has all of the error processing in it too: 它也包含所有错误处理:

        FB.ui
        ( 
            { 
                method : 'apprequests',
                data: '',
                display: 'dialog',
                title  : 'Invite a Friend',
                message: 'I just sent you an invitation to play My Game.',
                filters: ['app_non_users']
            }, function(response)
            {
                if (response && response.request_ids) 
                {
                    jQuery.ajax
                    (
                        {
                            url: 'Invite_Request.php',
                            type: 'GET',
                            data: 
                            {
                                'request_id': response.request_ids, 'signed_request': "<?php echo $_SESSION["SR"] ?>"
                            },
                            success: function(data) 
                            {
                                if (data.error) 
                                {
                                    //jQuery("#inviteMessages").html('successful call, but error! ' + data.message);
                                }
                                else 
                                {
                                    jQuery("#inviteMessages").html('successful request! ' + data.message);
                                }
                            },
                            error: function(xhr, status, msg) 
                            {
                                //jQuery("#inviteMessages").html('unsuccessful call, error! ' + status + ' ' + msg);
                            }
                        }
                    );
                    //jQuery("#inviteMessages").html('Successful request! Request ID = ' + response.request_ids);
                }
                else 
                {
                    //jQuery("#inviteMessages").html('Request failed!');
                }
            }
        );

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

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