简体   繁体   English

Linq2twitter ASP.NET C#不起作用

[英]Linq2twitter asp.net c# not working

Hey guys i followed the tutorial here for a school project, https://www.dougv.com/2015/08/posting-status-updates-to-twitter-via-linqtotwitter-part-2-plain-text-tweets/ 大家好,我在这里按照学校课程的教学指南进行操作, https://www.dougv.com/2015/08/posting-status-updates-to-twitter-via-linqtotwitter-part-2-plain-text-tweets/

But when i run it with google chrome nothing is showing up and it just stuck in http://localhost:2860/linq2twitter.aspx which is a blank page, i've checked my twitter the tweet has not been made as well.. from the other sample i've tried i think it is suppose to send me to a authentication page which requires me to login and stuff.. any help is appreciated. 但是,当我用google chrome运行它时,什么都没有显示,并且它停留在http:// localhost:2860 / linq2twitter.aspx ,这是一个空白页面,我已经检查了我的Twitter消息,也没有发出。从我尝试过的其他示例中,我认为应该将我发送到身份验证页面,该页面要求我登录和填写内容。 Here's my code : 这是我的代码:

namespace WebApplication3
{
public partial class linq2twitter : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    class Program
    {
        static void Main()
        {
            Console.WriteLine("Program started.");

            try
            {
                var result = Task.Run(() => SendTweet());
                result.Wait();
                if(result == null) {
                Console.WriteLine("Tweet failed to process, but API did not report an error");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Program completed.");
            Console.Read();
        }

        static async Task<Status> SendTweet()
        {
            var auth = new SingleUserAuthorizer
            {
                CredentialStore = new SingleUserInMemoryCredentialStore
                {
                    ConsumerKey = "<Twitter consumer key>",
                    ConsumerSecret = "<Twitter consumer secret>",
                    AccessToken = "<Twitter access token>",
                    AccessTokenSecret = "<Twitter access token secret>"
                }
            };

            var context = new TwitterContext(auth);

            var status = await context.TweetAsync(
            "Hello World! I am testing @dougvdotcom's #LinqToTwitter demo, at " +
            "https://www.dougv.com/2015/08/posting-status-updates-to-twitter-via-linqtotwitter-part-2-plain-text-tweets"
            );

            return status;
        }
    }
}
}

Fixed after regenerating my secrets and keys.. and removed unintentional spacebar for my keys in the code. 在重新生成我的秘密和密钥后修复。并在代码中删除了我的密钥的无意空格键。 Thx 谢谢

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

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