Invite users to register at my site through Facebo

2019-09-01 19:51发布

问题:

I read a lot of documentation and watched a video about Facebook C# SDK but I still cannot get my head around it! I need to do the following but I do not know if that's even possible...

  1. User clicks on a button on mysite.com. The button opens up a dialog that asks the user to sign-in with their facebook account. In case they do, I need to access their friends' list and send invites to their friends asking them to register at mysite.com
  2. The invite links should take them to mysite.com/User/Register?code=

Now the thing I do not understand is would the invites actually take them to my site? Or simply invite their friends to use a "facebook application"? I understand that I need a Facebook app in order to get an AppId and some other stuff that are required for authentication. But, the application will not really do anything!! And I do not want the users to land on some Facebook page after they've accepted the invitation, I want them to be taken to the registration page on mysite.com.

UPDATE:

Ok I'm starting to get the hang of it... I'm trying to post on my wall from the application, but nothing showed up... It asked for the post permissions but there seems to be something wrong... Here's my code:

    [CanvasAuthorize(Permissions = "user_about_me,publish_stream")]
    public ActionResult Index()
    {
        var fb = new FacebookWebClient();

        dynamic result = fb.Get("me");

        var postArgs = new Dictionary<string, string>();
        postArgs["message"] = "This is just a test message from the Facebook test application!";
        var post = fb.Post("/me/feed", postArgs);

        return RedirectToAction("About");
    }

Any thoughts?

回答1:

What you have described is certainly possible, in fact I have implemented something very similar on my site.

Firstly, yes, you do need to register a Facebook application, but you only need to do this in order to get an Application ID.

When the user registers/signs-in to your site, you can post a message on their wall which will be seen by all their friends (assuming you have the publish_stream permission for the user, see this Facebook reference document). You can include a link back to the registration page on your website in this post.

Or you could use the Facebook request form (fb:request-form) to send an invite to their friends. I've never used this, but it looks like (from the ASP.net example) that you could redirect them back to your site.

Hope this helps.