{"id":2964,"date":"2012-01-23T18:30:42","date_gmt":"2012-01-23T00:30:42","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/archives\/2964"},"modified":"2012-01-23T18:50:21","modified_gmt":"2012-01-23T09:50:21","slug":"linqtotwitter-%e3%82%92%e4%bd%bf%e3%81%86","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/2964","title":{"rendered":"LinqToTwitter \u3092\u4f7f\u3046"},"content":{"rendered":"<p>\n\u30c4\u30a4\u30fc\u30c8\u30ad\u30e3\u30c3\u30c1\u2605\u2605\u2605\u3092 <a href=\"http:\/\/linqtotwitter.codeplex.com\/\">LINQ to Twitter<\/a> \u3092\u4f7f\u3046\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u4e2d&#8230;\u3068\u8a00\u3044\u307e\u3059\u304b\u3001\u306a\u3093\u304b\u3001LINQ to Twitter \u3063\u3066\u3001\u5185\u90e8\u3067 Invoke \u3092\u3057\u3066\u3044\u308b\u3089\u3057\u304f\u3001\u30b5\u30fc\u30d0\u30fc\u30a8\u30e9\u30fc\u6642\u306e\u6319\u52d5\u304c\u304a\u304b\u3057\u3044\u3093\u3067\u3059\u3088\u306d\u3002\u306a\u306e\u3067\u3001Twitter \u304c\u4e0d\u5b89\u5b9a\u306a\u6642\u306e\u5bfe\u51e6\u304c\u96e3\u3057\u3044\u3001\u3068\u3044\u3046\u306e\u304c\u524d\u7f6e\u304d\u306a\u306e\u3067\u3059\u304c\u3002\n<\/p>\n<p>\n\u3068\u306f\u4e91\u3048\u3001\u4f7f\u3044\u65b9\u306f\u7d50\u69cb\u7c21\u5358\u3067\u3059\u3002LINQ \u3092\u4f7f\u3063\u3066\u691c\u7d22\u3059\u308b\u306e\u3067\u3001\u691c\u7d22\u7cfb\u306fOK\u304b\u3068\u3002\u66f4\u65b0\u7cfb\u306f\u3069\u3046\u306a\u306e\u304b\u3044\u307e\u3044\u3061\u78ba\u8a8d\u3057\u3066\u306a\u3044\u306e\u3067\u30c4\u30a4\u30fc\u30c8\u5c02\u7528\u306e\u307b\u3046\u306f\u3001TwiLib \u3092\u4f7f\u3063\u305f\u307e\u307e\u306a\u3093\u3067\u3059\u304c\u3002\n<\/p>\n<p>\n\u4f8b\u3048\u3070\u3001\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u4eba\u306e\u30c4\u30a4\u30fc\u30c8\u6570\u3092\u53d6\u5f97\u3059\u308b\u306e\u306f\u3001\u3053\u3093\u306a\u306b\u7c21\u5358\u306b\u66f8\u3051\u307e\u3059\u3002twitter \u304c\u8fd4\u3057\u3066\u304f\u308b xml \u306e\u8981\u7d20\u540d\u3068\u3001linq to twitter \u3067\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u540d\u3068\u306e\u300c\u305a\u308c\u300d\u304c\u3001\u3044\u307e\u3044\u3061\u5206\u304b\u308a\u3065\u3089\u3044\u306e\u3067\u3059\u304c\u3001\u6163\u308c\u308c\u3070\u306a\u3093\u3068\u304b\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ \u30c4\u30a4\u30fc\u30c8\u6570\u3092\u53d6\u5f97\r\nvar ctx = new TwitterContext(this.auth);\r\nvar user = (from t in ctx.User \r\n\t\t\twhere t.Type == UserType.Show &&\r\n\t\t\tt.ScreenName == username\r\n\t\t\tselect t).First();\r\nthis.profile_image_url = user.ProfileImageUrl;\r\nthis.tweet_count = user.StatusesCount;\r\n<\/pre>\n<p>\n\u3067\u3001\u5177\u4f53\u7684\u306b oauth \u8a8d\u8a3c\u3092\u3069\u3046\u3059\u308b\u304b\u3068\u3044\u3046\u3068\u3001\u30c4\u30a4\u30fc\u30c8\u30ad\u30e3\u30c3\u30c1\u3067\u306f\u6b21\u306e\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nif (accessToken == &amp;quot;&amp;quot;)\r\n{\r\n\tauth = new PinAuthorizer();\r\n\tauth.Credentials = new InMemoryCredentials {\r\n\t\tConsumerKey = this.consumerKey,\r\n\t\tConsumerSecret = this.consumerSecret \r\n\t};\r\n\tauth.UseCompression = false;\r\n\tauth.GoToTwitterAuthorization = link =&gt; {\r\n\t\tProcess.Start(link);\r\n\t};\r\n\tauth.GetPin = () =&gt;\r\n\t{\r\n\t\tFormAuth frm = new FormAuth();\r\n\t\tfrm.ShowDialog();\r\n\t\treturn frm.PinCode;\r\n\t};\r\n\tauth.Authorize();\r\n\tthis.SavaAuth();\r\n\treturn;\r\n}\r\nauth = new PinAuthorizer();\r\nauth.Credentials = new InMemoryCredentials\r\n{\r\n\tConsumerKey = this.consumerKey,\r\n\tConsumerSecret = this.consumerSecret\r\n};\r\nauth.OAuthTwitter.OAuthToken = this.accessToken;\r\nauth.OAuthTwitter.OAuthTokenSecret = this.accessSecret;\r\n<\/pre>\n<p>\noauth \u8a8d\u8a3c\u3092\u4f7f\u3046\u6642\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u3068\u3057\u3066\u3001\n<\/p>\n<ul>\n<li>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u4f7f\u3046 consumerKey <\/li>\n<li>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u4f7f\u3046 consumerSecret<\/li>\n<\/ul>\n<p>\n\u306e\u30bb\u30c3\u30c8\u3068\n<\/p>\n<ul>\n<li>\u8a8d\u8a3c\u5f8c\u306b\u4f7f\u3046 accessToken<\/li>\n<li>\u8a8d\u8a3c\u5f8c\u306b\u4f7f\u3046 accessSecret<\/li>\n<\/ul>\n<p>\n\u306e4\u3064\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u3042\u308a\u307e\u3059\u3002\n<\/p>\n<p>\n\u624b\u9806\u3068\u3057\u3066\u306f\u3001\n<\/p>\n<ol>\n<li>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b\u3068\u304d\u306b consumerKey \u3068 consumerSecret \u3092\u53d6\u5f97\uff08\u30a2\u30d7\u30ea\u306b\u66f8\u304d\u8fbc\u3080\u3001app.config\u3068\u304b\uff09<\/li>\n<li>\u30e6\u30fc\u30b6\u30fc\u304c\u521d\u56de\u5b9f\u884c\u6642\u306b consumerKey \u3068 consumerSecret \u3092\u4f7f\u3063\u3066 pincode \u3092\u5f97\u308b\u3002<\/li>\n<li>pincode \u3092\u4f7f\u3063\u3066\u3001accessToken \u3068 accessSecret \u306e\u30bb\u30c3\u30c8\u3092\u5f97\u308b\u3002<\/li>\n<p>  web \u306a\u3089\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u540d\u3068\u7d10\u3065\u3051\u3066\u4fdd\u6301\u3001winodws \u30a2\u30d7\u30ea\u306a\u3089\u3070\u30ec\u30b8\u30b9\u30c8\u30ea\u3068\u304b\u306b\u4fdd\u5b58<\/li>\n<li>\u6b21\u56de\u4ee5\u964d\u306f\u3001consumerKey, consumerSecret, accessToken, accessSecret \u306e 4\u3064\u304c\u3042\u308c\u3070 ok <\/li>\n<\/ol>\n<p>\n\u3068\u3044\u3046\u5177\u5408\u3067\u3059\u3002\n<\/p>\n<p>\n\u306a\u306e\u3067\u3001\u30ef\u30f3\u30af\u30c3\u30b7\u30e7\u30f3\u3060\u3051\u30e6\u30fc\u30b6\u30fc\u306b pincode \u3092\u5165\u529b\u3057\u3066\u8cb0\u3046\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067\u3059\u3002\u307e\u3041\u3001\u3053\u308c\u304c\u8a8d\u8a3c\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002\u52ff\u8ad6\u3001\u5185\u90e8\u30d6\u30e9\u30a6\u30b6\u3067\u8868\u793a\u3055\u305b\u305f\u308a\u3057\u3066\u3001pincode \u3092\u81ea\u52d5\u5165\u529b\u3055\u305b\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u304c\u3001\u624b\u5165\u529b\u3067\u3082\u5bfe\u3057\u3066\u624b\u9593\u3058\u3083\u306a\u3044\u306e\u3067\u305d\u306e\u307e\u307e\u3002\n<\/p>\n<p>\n\u3067\u3001linq to twitter \u306f\u3053\u306e pincode \u3092\u5165\u529b\u3059\u308b\u3068\u3053\u304c\u3084\u3084\u3053\u3057\u304f\u3066\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b GetPin \u306b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3092\u767b\u9332\u3055\u305b\u307e\u3059\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\tauth.GetPin = () =&gt;\r\n\t{\r\n\t\tFormAuth frm = new FormAuth();\r\n\t\tfrm.ShowDialog();\r\n\t\treturn frm.PinCode;\r\n\t};\r\n<\/pre>\n<p>\n\u3069\u3046\u3057\u3088\u3046\u304b\u3068\u60a9\u3093\u3060\u306e\u3067\u3059\u304c\u3001\u30c4\u30a4\u30fc\u30c8\u30ad\u30e3\u30c3\u30c1\u2605\u2605\u2605\u3067\u306f\u3001\u5225\u306e\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u51fa\u3057\u3066\u5bfe\u51e6\u3092\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002\n<\/p>\n<p>\nlinq \u306f\u691c\u7d22\u306e\u307b\u3046\u3092\u5f97\u610f\u3068\u3059\u308b\u306e\u3067\u3001\u76f4\u8fd1\u306e\u30c4\u30a4\u30fc\u30c8\u3092\u53d6\u5f97\u306a\u3093\u3066\u306e\u306f\u3001\u3053\u3093\u306a\u98a8\u306b\u66f8\u3051\u307e\u3059\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/\/ &lt;summary&gt;\r\n\/\/\/ \u30c4\u30a4\u30fc\u30c8\u3092\u53d6\u5f97\r\n\/\/\/ &lt;\/summary&gt;\r\n\/\/\/ &lt;param name=&amp;quot;sname&amp;quot;&gt;&lt;\/param&gt;\r\n\/\/\/ &lt;param name=&amp;quot;max_id&amp;quot;&gt;&lt;\/param&gt;\r\n\/\/\/ &lt;returns&gt;&lt;\/returns&gt;\r\nprivate List&lt;Status&gt; GetTweets(string sname, string max_id = &amp;quot;&amp;quot;)\r\n{\r\n\tvar ctx = new TwitterContext(this.auth);\r\n\tvar items = from t in ctx.Status\r\n\t\t\t\twhere t.Type == StatusType.User\r\n\t\t\t\t&amp;&amp; t.ScreenName == username\r\n\t\t\t\t&amp;&amp; t.Count == MAX_TWEET\r\n\t\t\t\t&amp;&amp; t.MaxID == max_id\r\n\t\t\t\tselect t;\r\n\tvar lst = items.ToList&lt;Status&gt;();\r\n\treturn lst;\r\n}\r\n<\/pre>\n<p>\n # MaxID \u306f\u30af\u30ed\u30fc\u30ea\u30f3\u30b0\u306e\u305f\u3081\u306b\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u5143\u306e\u30bd\u30fc\u30b9\u306f int \u578b\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002\u30bd\u30fc\u30b9\u3092 string \u578b\u306b\u9069\u5f53\u306b\u76f4\u3057\u3066\u3044\u307e\u3059\u3002\u73fe\u5728\u3001twitter id \u306f int\u306e\u7bc4\u56f2\u3092\u8d85\u3048\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u306e\u3067\u3001string \u3067\u4fdd\u6301\u3059\u308b\u306e\u304c\u3088\u3044\u3067\u3057\u3087\u3046\u3002\n<\/p>\n<p>\n\u5b9f\u306f\u3001\u6700\u5927\u306e\u96e3\u95a2\u304c\u30b5\u30fc\u30d0\u30fc\u30a8\u30e9\u30fc\u306e\u5bfe\u51e6\u306a\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u307e\u307e\u3067\u306f\u3046\u307e\u304f\u52d5\u304b\u306a\u3044\u306e\u3067\u8ae6\u3081\u307e\u3057\u305f\u3002<br \/>\n\u306a\u306e\u3067\u3001\u8a66\u3057\u306b oauth \u8a8d\u8a3c\u306e\u90e8\u5206\u3060\u3051 linq to twitter \u306e\u30b3\u30fc\u30c9\u3092\u4f7f\u3063\u3066\u3001\u623b\u3055\u308c\u3066\u304d\u305f xml \u30c7\u30fc\u30bf\u306f\u81ea\u524d\u3067\u89e3\u6790\u3059\u308b\u3068\u3044\u3046\u306e\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u3053\u306e\u8a71\u3057\u306f\u5225\u306e\u8a18\u4e8b\u3067\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30c4\u30a4\u30fc\u30c8\u30ad\u30e3\u30c3\u30c1\u2605\u2605\u2605\u3092 LINQ to Twitter \u3092\u4f7f\u3046\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u4e2d&#8230;\u3068\u8a00\u3044\u307e\u3059\u304b\u3001\u306a\u3093\u304b\u3001LINQ to Twitter \u3063\u3066\u3001\u5185\u90e8\u3067 Invoke \u3092\u3057\u3066\u3044\u308b\u3089\u3057\u304f\u3001\u30b5\u30fc\u30d0\u30fc\u30a8\u30e9\u30fc\u6642\u306e\u6319\u52d5\u304c\u304a &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/2964\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[23],"tags":[],"class_list":["post-2964","post","type-post","status-publish","format-standard","hentry","category-csharp"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2964","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=2964"}],"version-history":[{"count":1,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2964\/revisions"}],"predecessor-version":[{"id":2965,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2964\/revisions\/2965"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=2964"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=2964"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=2964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}