Twitter的API应用程序的唯一身份验证(带linq2twitter) [英] Twitter API application-only authentication (with linq2twitter)

查看:136
本文介绍了Twitter的API应用程序的唯一身份验证(带linq2twitter)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现Twitter的API应用程序唯一的身份验证,我已经通过<一个搜索href=\"http://linqtotwitter.$c$cplex.com/wikipage?title=Learning%20to%20use%20OAuth&referringTitle=Securing%20Your%20Applications\">linq2twitter OAuth的样品以及StackOverflow的问题,但我没有发现任何关于它的帮助。

I need to implement Twitter API application-only authentication and I've searched through linq2twitter oauth samples and stackoverflow questions, but I didn't find anything helpful about it.

是否有可能实现这种与linq2twitter如何授权?

Is it possible to implement this kind of authorization with linq2twitter and how?

推荐答案

当然是。这里有一个例子:

Sure is. Here's an example:

        var auth = new ApplicationOnlyAuthorizer
        {
            Credentials = new InMemoryCredentials
            {
                ConsumerKey = "twitterConsumerKey",
                ConsumerSecret = "twitterConsumerSecret"
            }
        };

        auth.Authorize();
        //auth.Invalidate();

        var twitterCtx = new TwitterContext(auth);

        var srch =
            (from search in twitterCtx.Search
             where search.Type == SearchType.Search &&
                   search.Query == "LINQ to Twitter"
             select search)
            .SingleOrDefault();

        Console.WriteLine("\nQuery: {0}\n", srch.SearchMetaData.Query);
        srch.Statuses.ForEach(entry =>
            Console.WriteLine(
                "ID: {0, -15}, Source: {1}\nContent: {2}\n",
                entry.StatusID, entry.Source, entry.Text));

有在下载的源$ C ​​$ C的LinqToTwitterDemo项目运行的例子。 Program.cs文件具有唯一的应用程序的选项。还有,有一个例子的OAuthDemos.cs文件

There are running examples in the LinqToTwitterDemo project of the downloadable source code. The Program.cs file has an option for Application Only. There's also an OAuthDemos.cs file that has an example.

这篇关于Twitter的API应用程序的唯一身份验证(带linq2twitter)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆