Sending Facebook Invitations & Tracking Invitation Codes

删除回忆录丶 提交于 2019-12-08 07:59:42

问题


This is a follow up to Invite users to register at my site through Facebook.

I'm still working within a prototype application for now. I managed to use the Javascript API to send out invitations, but I'm having problems parsing the response object. Here's my code:

<a href="#">Send Application Request</a>
<div id="fb-root"></div>
<script type="text/javascript">
    window.fbAsyncInit = function() {
        FB.init({
          appId   : '193005690721590',
          status  : true,
          cookie  : true,
          xfbml   : true
        });
    };

    $('a').click(sendRequest);
    function sendRequest() {
        FB.ui({
            method: 'apprequests',
            message: 'Invitation to the test application!',
            title: 'Send your friends an application request',
            data: 'someCode'
        },
        function (response) {
            if (response && response.request_ids) {
                var requests = response.request_ids.join(',');
                console.log(requests);
                console.log(response);
                var obj = $.parseJSON(response);
                $.ajax({
                    url: '/Home/Parse',
                    type: 'post',
                    data: obj,
                    contentType: 'application/json; charset=utf-8',
                    success: function (data) {
                        if (data.result === 'ok') {
                            alert("Everything went fine");
                            //top.location.href = '/Home/About';
                        }
                    }
                });
            } else {
                alert('canceled');
            }
        });
        return false;
    }

    (function() {
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
    }());
</script>

And here's the action method that is supposed to parse the object, but for now I just want to check out the schema of the object using the debugger:

    [HttpPost]
    public ActionResult Parse(JsonObject response)
    {
        //parse the response object 

        return Json(new {result = "ok"});
    }

But, unfortunately, the response JsonObject appears to be null!

So how do I get this to work?

On a side not, is it possible to use the Facebook C# SDK to do the Request dialog stuff instead of using the Javascript API?

来源:https://stackoverflow.com/questions/5975696/sending-facebook-invitations-tracking-invitation-codes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!