Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 允许在共享url后访问_Asp.net Mvc_Facebook_Twitter - Fatal编程技术网

Asp.net mvc 允许在共享url后访问

Asp.net mvc 允许在共享url后访问,asp.net-mvc,facebook,twitter,Asp.net Mvc,Facebook,Twitter,在MVC5网站上,我希望访问者只有在Facebook或Twitter上分享后才能阅读文章的完整版本 我在一些网站上看到过这个例子。。。最好的方法是什么 这里没有真正的安全问题。。。这只是一种传播信息的方式 我的第一个想法是用post键(Guid)保存cookie。。。该键对用户不可见,因此用户不知道该值 问题是我怎么知道他共享了url。。。我怎样才能得到确认 谢谢, 米格尔您可以通过以下方式获得确认: 我在一个.NET项目中几乎一字不差地实现了这段代码(只是用我自己的功能替换了警报),在该项目中

在MVC5网站上,我希望访问者只有在Facebook或Twitter上分享后才能阅读文章的完整版本

我在一些网站上看到过这个例子。。。最好的方法是什么

这里没有真正的安全问题。。。这只是一种传播信息的方式

我的第一个想法是用post键(Guid)保存cookie。。。该键对用户不可见,因此用户不知道该值

问题是我怎么知道他共享了url。。。我怎样才能得到确认

谢谢,


米格尔

您可以通过以下方式获得确认:

我在一个.NET项目中几乎一字不差地实现了这段代码(只是用我自己的功能替换了
警报
),在该项目中,如果用户共享竞赛页面,我会给他们两个参赛条目(而不是如果他们不共享或什么都不做,则给他们一个条目)


至于Twitter,我个人还没有实现类似的功能,但你最好的选择可能是。

我不知道Facebook,但对于Twitter,转发与共享是一样的。状态/转发者/ID应该有效。如果你有tweet的id,那么你可以持有转发者的列表,根据需要进行更新以获得新id

如果不想编写所有代码来验证和配置端点,可以使用第三方库。这是我的图书馆里的一个例子:

顺便说一句,还有一个

FB.ui(
{
    method: 'feed',
    name: 'Facebook Dialogs',
    link: 'https://developers.facebook.com/docs/dialogs/',
    picture: 'http://fbrell.com/f8.jpg',
    caption: 'Reference Documentation',
    description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
},
function(response) {
    if (response && response.post_id) {
      alert('Post was shared.'); //give access to article
    } else {
      alert('Post was not shared.'); //they chose not share... don't give access
    }
});
        ulong tweetID = 210591841312190464;

        var status =
            await
            (from tweet in twitterCtx.Status
             where tweet.Type == StatusType.Retweeters &&
                   tweet.ID == tweetID
             select tweet)
            .SingleOrDefaultAsync();

        if (status != null && status.User != null)
            status.Users.ForEach(
                userID => Console.WriteLine("User ID: " + userID));