開発に使用するリポジトリ
修訂 | a7a71a06ea64f6ae2e28f576b0e854b236e5732b (tree) |
---|---|
時間 | 2013-08-30 05:06:21 |
作者 | Kimura Youichi <kim.upsilon@bucy...> |
Commiter | Kimura Youichi |
REST API v1 など古いAPIのコードを除去
@@ -24,6 +24,7 @@ using System.Collections.Generic; | ||
24 | 24 | using System.Linq; |
25 | 25 | using System.Text; |
26 | 26 | using NUnit.Framework; |
27 | +using System.Xml; | |
27 | 28 | |
28 | 29 | namespace OpenTween.Api |
29 | 30 | { |
@@ -35,13 +36,13 @@ namespace OpenTween.Api | ||
35 | 36 | { |
36 | 37 | var apiStatus = new TwitterApiStatus(); |
37 | 38 | |
38 | - apiStatus.AccessLimit = new ApiLimit(150, 100, new DateTime(2013, 1, 1, 0, 0, 0)); | |
39 | + apiStatus.AccessLimit["/statuses/home_timeline"] = new ApiLimit(150, 100, new DateTime(2013, 1, 1, 0, 0, 0)); | |
39 | 40 | apiStatus.MediaUploadLimit = new ApiLimit(150, 100, new DateTime(2013, 1, 1, 0, 0, 0)); |
40 | 41 | apiStatus.AccessLevel = TwitterApiAccessLevel.ReadWriteAndDirectMessage; |
41 | 42 | |
42 | 43 | apiStatus.Reset(); |
43 | 44 | |
44 | - Assert.That(apiStatus.AccessLimit, Is.Null); | |
45 | + Assert.That(apiStatus.AccessLimit["/statuses/home_timeline"], Is.Null); | |
45 | 46 | Assert.That(apiStatus.MediaUploadLimit, Is.Null); |
46 | 47 | Assert.That(apiStatus.AccessLevel, Is.EqualTo(TwitterApiAccessLevel.Anonymous)); |
47 | 48 | } |
@@ -160,18 +161,18 @@ namespace OpenTween.Api | ||
160 | 161 | |
161 | 162 | var header = new Dictionary<string, string> |
162 | 163 | { |
163 | - {"X-RateLimit-Limit", "150"}, | |
164 | - {"X-RateLimit-Remaining", "100"}, | |
165 | - {"X-RateLimit-Reset", "1356998400"}, | |
164 | + {"X-Rate-Limit-Limit", "150"}, | |
165 | + {"X-Rate-Limit-Remaining", "100"}, | |
166 | + {"X-Rate-Limit-Reset", "1356998400"}, | |
166 | 167 | {"X-MediaRateLimit-Limit", "30"}, |
167 | 168 | {"X-MediaRateLimit-Remaining", "20"}, |
168 | 169 | {"X-MediaRateLimit-Reset", "1357084800"}, |
169 | 170 | {"X-Access-Level", "read-write-directmessages"}, |
170 | 171 | }; |
171 | 172 | |
172 | - status.UpdateFromHeader(header); | |
173 | + status.UpdateFromHeader(header, "/statuses/home_timeline"); | |
173 | 174 | |
174 | - var rateLimit = status.AccessLimit; | |
175 | + var rateLimit = status.AccessLimit["/statuses/home_timeline"]; | |
175 | 176 | Assert.That(rateLimit.AccessLimitCount, Is.EqualTo(150)); |
176 | 177 | Assert.That(rateLimit.AccessLimitRemain, Is.EqualTo(100)); |
177 | 178 | Assert.That(rateLimit.AccessLimitResetDate, Is.EqualTo(new DateTime(2013, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime())); |
@@ -187,84 +188,37 @@ namespace OpenTween.Api | ||
187 | 188 | } |
188 | 189 | |
189 | 190 | [Test] |
190 | - public void UpdateFromApiTest() | |
191 | + public void UpdateFromJsonTest() | |
191 | 192 | { |
192 | 193 | var status = new TwitterApiStatus(); |
193 | 194 | |
194 | 195 | var eventCalled = false; |
195 | 196 | status.AccessLimitUpdated += (s, e) => eventCalled = true; |
196 | 197 | |
197 | - var apiResponse = new TwitterDataModel.RateLimitStatus | |
198 | - { | |
199 | - HourlyLimit = 150, | |
200 | - RemainingHits = 100, | |
201 | - ResetTime = "Tue Jan 01 00:00:00 +0000 2013", | |
202 | - ResetTimeInSeconds = 1356998400, | |
203 | - Photos = new TwitterDataModel.MediaRateLimitStatus | |
204 | - { | |
205 | - DailyLimit = 30, | |
206 | - RemainingHits = 20, | |
207 | - ResetTime = "Wed Jan 02 00:00:00 +0000 2013", | |
208 | - RestTimeInSeconds = 1357084800, | |
209 | - }, | |
210 | - }; | |
211 | - | |
212 | - status.UpdateFromApi(apiResponse); | |
213 | - | |
214 | - var rateLimit = status.AccessLimit; | |
215 | - Assert.That(rateLimit.AccessLimitCount, Is.EqualTo(150)); | |
216 | - Assert.That(rateLimit.AccessLimitRemain, Is.EqualTo(100)); | |
217 | - Assert.That(rateLimit.AccessLimitResetDate, Is.EqualTo(new DateTime(2013, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime())); | |
218 | - | |
219 | - var mediaLimit = status.MediaUploadLimit; | |
220 | - Assert.That(mediaLimit.AccessLimitCount, Is.EqualTo(30)); | |
221 | - Assert.That(mediaLimit.AccessLimitRemain, Is.EqualTo(20)); | |
222 | - Assert.That(mediaLimit.AccessLimitResetDate, Is.EqualTo(new DateTime(2013, 1, 2, 0, 0, 0, DateTimeKind.Utc).ToLocalTime())); | |
223 | - | |
224 | - Assert.That(eventCalled, Is.True); | |
225 | - } | |
226 | - | |
227 | - [Test] | |
228 | - public void UpdateFromApiTest2() | |
229 | - { | |
230 | - var status = new TwitterApiStatus(); | |
231 | - | |
232 | - var eventCalled = false; | |
233 | - status.AccessLimitUpdated += (s, e) => eventCalled = true; | |
198 | + var json = "{\"resources\":{\"statuses\":{\"/statuses/home_timeline\":{\"limit\":150,\"remaining\":100,\"reset\":1356998400}}}}"; | |
199 | + status.UpdateFromJson(json); | |
234 | 200 | |
235 | - var apiResponse = new TwitterDataModel.RateLimitStatus | |
236 | - { | |
237 | - HourlyLimit = 150, | |
238 | - RemainingHits = 100, | |
239 | - ResetTime = "Tue Jan 01 00:00:00 +0000 2013", | |
240 | - ResetTimeInSeconds = 1356998400, | |
241 | - Photos = null, | |
242 | - }; | |
243 | - | |
244 | - status.UpdateFromApi(apiResponse); | |
245 | - | |
246 | - var rateLimit = status.AccessLimit; | |
201 | + var rateLimit = status.AccessLimit["/statuses/home_timeline"]; | |
247 | 202 | Assert.That(rateLimit.AccessLimitCount, Is.EqualTo(150)); |
248 | 203 | Assert.That(rateLimit.AccessLimitRemain, Is.EqualTo(100)); |
249 | 204 | Assert.That(rateLimit.AccessLimitResetDate, Is.EqualTo(new DateTime(2013, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime())); |
250 | 205 | |
251 | - Assert.That(status.MediaUploadLimit, Is.Null); | |
252 | - | |
253 | 206 | Assert.That(eventCalled, Is.True); |
254 | 207 | } |
255 | 208 | |
256 | 209 | [Test] |
257 | - public void UpdateFromApiTest3() | |
210 | + public void UpdateFromJsonTest2() | |
258 | 211 | { |
259 | 212 | var status = new TwitterApiStatus(); |
260 | 213 | |
261 | 214 | var eventCalled = false; |
262 | 215 | status.AccessLimitUpdated += (s, e) => eventCalled = true; |
263 | 216 | |
264 | - Assert.That(() => status.UpdateFromApi(null), Throws.TypeOf<ArgumentNullException>()); | |
217 | + var json = "INVALID JSON"; | |
218 | + Assert.That(() => status.UpdateFromJson(json), Throws.TypeOf<XmlException>()); | |
265 | 219 | |
266 | - Assert.That(status.AccessLimit, Is.Null); | |
267 | - Assert.That(status.MediaUploadLimit, Is.Null); | |
220 | + var rateLimit = status.AccessLimit["/statuses/home_timeline"]; | |
221 | + Assert.That(rateLimit, Is.Null); | |
268 | 222 | |
269 | 223 | Assert.That(eventCalled, Is.False); |
270 | 224 | } |
@@ -279,7 +233,7 @@ namespace OpenTween.Api | ||
279 | 233 | |
280 | 234 | Assert.That(eventCount, Is.EqualTo(0)); |
281 | 235 | |
282 | - apiStatus.AccessLimit = new ApiLimit(150, 100, new DateTime(2013, 1, 1, 0, 0, 0)); | |
236 | + apiStatus.AccessLimit["/statuses/home_timeline"] = new ApiLimit(150, 100, new DateTime(2013, 1, 1, 0, 0, 0)); | |
283 | 237 | Assert.That(eventCount, Is.EqualTo(1)); |
284 | 238 | |
285 | 239 | apiStatus.Reset(); |
@@ -65,39 +65,21 @@ namespace OpenTween | ||
65 | 65 | { |
66 | 66 | // toolStrip.ApiLimit の初期値は null |
67 | 67 | |
68 | - Assert.That(toolStrip.Text, Is.EqualTo("API v1.1 ???/???")); | |
68 | + Assert.That(toolStrip.Text, Is.EqualTo("API ???/???")); | |
69 | 69 | Assert.That(toolStrip.ToolTipText, Is.EqualTo("API rest ???/???" + Environment.NewLine + "(reset after ??? minutes)")); |
70 | 70 | |
71 | 71 | toolStrip.ApiLimit = new ApiLimit(15, 14, DateTime.Now.AddMinutes(15)); |
72 | 72 | |
73 | - Assert.That(toolStrip.Text, Is.EqualTo("API v1.1 14/15")); | |
73 | + Assert.That(toolStrip.Text, Is.EqualTo("API 14/15")); | |
74 | 74 | Assert.That(toolStrip.ToolTipText, Is.EqualTo("API rest 14/15" + Environment.NewLine + "(reset after 15 minutes)")); |
75 | 75 | |
76 | 76 | toolStrip.ApiLimit = null; |
77 | 77 | |
78 | - Assert.That(toolStrip.Text, Is.EqualTo("API v1.1 ???/???")); | |
78 | + Assert.That(toolStrip.Text, Is.EqualTo("API ???/???")); | |
79 | 79 | Assert.That(toolStrip.ToolTipText, Is.EqualTo("API rest ???/???" + Environment.NewLine + "(reset after ??? minutes)")); |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - [Test] | |
84 | - public void API11EnabledTest() | |
85 | - { | |
86 | - using (var toolStrip = new ToolStripAPIGauge()) | |
87 | - { | |
88 | - // toolStrip.API11Enabled の初期値は true | |
89 | - Assert.That(toolStrip.Text, Is.EqualTo("API v1.1 ???/???")); | |
90 | - | |
91 | - toolStrip.API11Enabled = false; | |
92 | - | |
93 | - Assert.That(toolStrip.Text, Is.EqualTo("API v1 ???/???")); | |
94 | - | |
95 | - toolStrip.API11Enabled = true; | |
96 | - | |
97 | - Assert.That(toolStrip.Text, Is.EqualTo("API v1.1 ???/???")); | |
98 | - } | |
99 | - } | |
100 | - | |
101 | 83 | class TestToolStripAPIGauge : ToolStripAPIGauge |
102 | 84 | { |
103 | 85 | public DateTime Now { get; set; } // 現在時刻 |
@@ -22,55 +22,41 @@ | ||
22 | 22 | using System; |
23 | 23 | using System.Collections.Generic; |
24 | 24 | using System.Linq; |
25 | +using System.Runtime.Serialization.Json; | |
25 | 26 | using System.Text; |
27 | +using System.Xml; | |
28 | +using System.Xml.Linq; | |
29 | +using System.Xml.XPath; | |
26 | 30 | |
27 | 31 | namespace OpenTween.Api |
28 | 32 | { |
29 | 33 | public class TwitterApiStatus |
30 | 34 | { |
31 | - public ApiLimit AccessLimit | |
35 | + public TwitterApiAccessLevel AccessLevel { get; set; } | |
36 | + public EndpointLimits AccessLimit { get; private set; } | |
37 | + public ApiLimit MediaUploadLimit { get; set; } | |
38 | + | |
39 | + public class AccessLimitUpdatedEventArgs : EventArgs | |
32 | 40 | { |
33 | - get { return this._AccessLimit; } | |
34 | - set | |
41 | + public readonly string EndpointName; | |
42 | + | |
43 | + public AccessLimitUpdatedEventArgs(string endpointName) | |
35 | 44 | { |
36 | - this._AccessLimit = value; | |
37 | - this.OnAccessLimitUpdated(EventArgs.Empty); | |
45 | + this.EndpointName = endpointName; | |
38 | 46 | } |
39 | 47 | } |
40 | - public ApiLimit _AccessLimit; | |
41 | - | |
42 | - public ApiLimit MediaUploadLimit { get; set; } | |
43 | - public TwitterApiAccessLevel AccessLevel { get; set; } | |
44 | - | |
45 | - public event EventHandler AccessLimitUpdated; | |
48 | + public event EventHandler<AccessLimitUpdatedEventArgs> AccessLimitUpdated; | |
46 | 49 | |
47 | - private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | |
48 | - | |
49 | - protected internal TwitterApiStatus() | |
50 | + public TwitterApiStatus() | |
50 | 51 | { |
51 | - this.Reset(); | |
52 | + this.AccessLimit = new EndpointLimits(this); | |
52 | 53 | } |
53 | 54 | |
54 | 55 | public void Reset() |
55 | 56 | { |
56 | - this.AccessLimit = null; | |
57 | - this.MediaUploadLimit = null; | |
58 | 57 | this.AccessLevel = TwitterApiAccessLevel.Anonymous; |
59 | - } | |
60 | - | |
61 | - public void UpdateFromHeader(IDictionary<string, string> header) | |
62 | - { | |
63 | - var rateLimit = TwitterApiStatus.ParseRateLimit(header, "X-RateLimit-"); | |
64 | - if (rateLimit != null) | |
65 | - this.AccessLimit = rateLimit; | |
66 | - | |
67 | - var mediaLimit = TwitterApiStatus.ParseRateLimit(header, "X-MediaRateLimit-"); | |
68 | - if (mediaLimit != null) | |
69 | - this.MediaUploadLimit = mediaLimit; | |
70 | - | |
71 | - var accessLevel = TwitterApiStatus.ParseAccessLevel(header, "X-Access-Level"); | |
72 | - if (accessLevel.HasValue) | |
73 | - this.AccessLevel = accessLevel.Value; | |
58 | + this.AccessLimit.Clear(); | |
59 | + this.MediaUploadLimit = null; | |
74 | 60 | } |
75 | 61 | |
76 | 62 | internal static ApiLimit ParseRateLimit(IDictionary<string, string> header, string prefix) |
@@ -121,26 +107,94 @@ namespace OpenTween.Api | ||
121 | 107 | } |
122 | 108 | |
123 | 109 | return null; |
124 | - } | |
110 | + } | |
125 | 111 | |
126 | - public void UpdateFromApi(TwitterDataModel.RateLimitStatus limit) | |
112 | + public void UpdateFromHeader(IDictionary<string, string> header, string endpointName) | |
127 | 113 | { |
128 | - if (limit == null) | |
129 | - throw new ArgumentNullException(); | |
130 | - | |
131 | - this.AccessLimit = new ApiLimit(limit.HourlyLimit, limit.RemainingHits, MyCommon.DateTimeParse(limit.ResetTime)); | |
114 | + var rateLimit = TwitterApiStatus.ParseRateLimit(header, "X-Rate-Limit-"); | |
115 | + if (rateLimit != null) | |
116 | + this.AccessLimit[endpointName] = rateLimit; | |
132 | 117 | |
133 | - var mediaLimit = limit.Photos; | |
118 | + var mediaLimit = TwitterApiStatus.ParseRateLimit(header, "X-MediaRateLimit-"); | |
134 | 119 | if (mediaLimit != null) |
120 | + this.MediaUploadLimit = mediaLimit; | |
121 | + | |
122 | + var accessLevel = TwitterApiStatus.ParseAccessLevel(header, "X-Access-Level"); | |
123 | + if (accessLevel.HasValue) | |
124 | + this.AccessLevel = accessLevel.Value; | |
125 | + } | |
126 | + | |
127 | + private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | |
128 | + | |
129 | + public void UpdateFromJson(string json) | |
130 | + { | |
131 | + using (var jsonReader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(json), XmlDictionaryReaderQuotas.Max)) | |
135 | 132 | { |
136 | - this.MediaUploadLimit = new ApiLimit(mediaLimit.DailyLimit, mediaLimit.RemainingHits, MyCommon.DateTimeParse(mediaLimit.ResetTime)); | |
133 | + var xElm = XElement.Load(jsonReader); | |
134 | + XNamespace a = "item"; | |
135 | + | |
136 | + var q = | |
137 | + from res in xElm.Element("resources").Descendants(a + "item") // a:item 要素を列挙 | |
138 | + select new { | |
139 | + endpointName = res.Attribute("item").Value, | |
140 | + limit = new ApiLimit( | |
141 | + int.Parse(res.Element("limit").Value), | |
142 | + int.Parse(res.Element("remaining").Value), | |
143 | + UnixEpoch.AddSeconds(long.Parse(res.Element("reset").Value)).ToLocalTime() | |
144 | + ), | |
145 | + }; | |
146 | + this.AccessLimit.AddAll(q.ToDictionary(x => x.endpointName, x => x.limit)); | |
137 | 147 | } |
138 | 148 | } |
139 | 149 | |
140 | - protected virtual void OnAccessLimitUpdated(EventArgs e) | |
150 | + protected virtual void OnAccessLimitUpdated(AccessLimitUpdatedEventArgs e) | |
141 | 151 | { |
142 | 152 | if (this.AccessLimitUpdated != null) |
143 | 153 | this.AccessLimitUpdated(this, e); |
144 | 154 | } |
155 | + | |
156 | + public class EndpointLimits | |
157 | + { | |
158 | + public readonly TwitterApiStatus Owner; | |
159 | + | |
160 | + private Dictionary<string, ApiLimit> innerDict = new Dictionary<string, ApiLimit>(); | |
161 | + | |
162 | + public EndpointLimits(TwitterApiStatus owner) | |
163 | + { | |
164 | + this.Owner = owner; | |
165 | + } | |
166 | + | |
167 | + public ApiLimit this[string endpoint] | |
168 | + { | |
169 | + get | |
170 | + { | |
171 | + if (this.innerDict.ContainsKey(endpoint)) | |
172 | + return this.innerDict[endpoint]; | |
173 | + | |
174 | + return null; | |
175 | + } | |
176 | + set | |
177 | + { | |
178 | + this.innerDict[endpoint] = value; | |
179 | + this.Owner.OnAccessLimitUpdated(new AccessLimitUpdatedEventArgs(endpoint)); | |
180 | + } | |
181 | + } | |
182 | + | |
183 | + public void Clear() | |
184 | + { | |
185 | + this.innerDict.Clear(); | |
186 | + this.Owner.OnAccessLimitUpdated(new AccessLimitUpdatedEventArgs(null)); | |
187 | + } | |
188 | + | |
189 | + public void AddAll(IDictionary<string, ApiLimit> resources) | |
190 | + { | |
191 | + foreach (var res in resources) | |
192 | + { | |
193 | + this.innerDict[res.Key] = res.Value; | |
194 | + } | |
195 | + | |
196 | + this.Owner.OnAccessLimitUpdated(new AccessLimitUpdatedEventArgs(null)); | |
197 | + } | |
198 | + } | |
145 | 199 | } |
146 | 200 | } |
@@ -1,150 +0,0 @@ | ||
1 | -// OpenTween - Client of Twitter | |
2 | -// Copyright (c) 2013 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/> | |
3 | -// All rights reserved. | |
4 | -// | |
5 | -// This file is part of OpenTween. | |
6 | -// | |
7 | -// This program is free software; you can redistribute it and/or modify it | |
8 | -// under the terms of the GNU General Public License as published by the Free | |
9 | -// Software Foundation; either version 3 of the License, or (at your option) | |
10 | -// any later version. | |
11 | -// | |
12 | -// This program is distributed in the hope that it will be useful, but | |
13 | -// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
14 | -// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | -// for more details. | |
16 | -// | |
17 | -// You should have received a copy of the GNU General Public License along | |
18 | -// with this program. If not, see <http://www.gnu.org/licenses/>, or write to | |
19 | -// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, | |
20 | -// Boston, MA 02110-1301, USA. | |
21 | - | |
22 | -using System; | |
23 | -using System.Collections.Generic; | |
24 | -using System.Linq; | |
25 | -using System.Runtime.Serialization.Json; | |
26 | -using System.Text; | |
27 | -using System.Xml; | |
28 | -using System.Xml.Linq; | |
29 | -using System.Xml.XPath; | |
30 | - | |
31 | -namespace OpenTween.Api | |
32 | -{ | |
33 | - public class TwitterApiStatus11 | |
34 | - { | |
35 | - public TwitterApiAccessLevel AccessLevel { get; set; } | |
36 | - public EndpointLimits AccessLimit { get; private set; } | |
37 | - public ApiLimit MediaUploadLimit { get; set; } | |
38 | - | |
39 | - public class AccessLimitUpdatedEventArgs : EventArgs | |
40 | - { | |
41 | - public readonly string EndpointName; | |
42 | - | |
43 | - public AccessLimitUpdatedEventArgs(string endpointName) | |
44 | - { | |
45 | - this.EndpointName = endpointName; | |
46 | - } | |
47 | - } | |
48 | - public event EventHandler<AccessLimitUpdatedEventArgs> AccessLimitUpdated; | |
49 | - | |
50 | - public TwitterApiStatus11() | |
51 | - { | |
52 | - this.AccessLimit = new EndpointLimits(this); | |
53 | - } | |
54 | - | |
55 | - public void Reset() | |
56 | - { | |
57 | - this.AccessLevel = TwitterApiAccessLevel.Anonymous; | |
58 | - this.AccessLimit.Clear(); | |
59 | - this.MediaUploadLimit = null; | |
60 | - } | |
61 | - | |
62 | - public void UpdateFromHeader(IDictionary<string, string> header, string endpointName) | |
63 | - { | |
64 | - var rateLimit = TwitterApiStatus.ParseRateLimit(header, "X-Rate-Limit-"); | |
65 | - if (rateLimit != null) | |
66 | - this.AccessLimit[endpointName] = rateLimit; | |
67 | - | |
68 | - var mediaLimit = TwitterApiStatus.ParseRateLimit(header, "X-MediaRateLimit-"); | |
69 | - if (mediaLimit != null) | |
70 | - this.MediaUploadLimit = mediaLimit; | |
71 | - | |
72 | - var accessLevel = TwitterApiStatus.ParseAccessLevel(header, "X-Access-Level"); | |
73 | - if (accessLevel.HasValue) | |
74 | - this.AccessLevel = accessLevel.Value; | |
75 | - } | |
76 | - | |
77 | - private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | |
78 | - | |
79 | - public void UpdateFromJson(string json) | |
80 | - { | |
81 | - using (var jsonReader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(json), XmlDictionaryReaderQuotas.Max)) | |
82 | - { | |
83 | - var xElm = XElement.Load(jsonReader); | |
84 | - XNamespace a = "item"; | |
85 | - | |
86 | - var q = | |
87 | - from res in xElm.Element("resources").Descendants(a + "item") // a:item 要素を列挙 | |
88 | - select new { | |
89 | - endpointName = res.Attribute("item").Value, | |
90 | - limit = new ApiLimit( | |
91 | - int.Parse(res.Element("limit").Value), | |
92 | - int.Parse(res.Element("remaining").Value), | |
93 | - UnixEpoch.AddSeconds(long.Parse(res.Element("reset").Value)).ToLocalTime() | |
94 | - ), | |
95 | - }; | |
96 | - this.AccessLimit.AddAll(q.ToDictionary(x => x.endpointName, x => x.limit)); | |
97 | - } | |
98 | - } | |
99 | - | |
100 | - protected virtual void OnAccessLimitUpdated(AccessLimitUpdatedEventArgs e) | |
101 | - { | |
102 | - if (this.AccessLimitUpdated != null) | |
103 | - this.AccessLimitUpdated(this, e); | |
104 | - } | |
105 | - | |
106 | - public class EndpointLimits | |
107 | - { | |
108 | - public readonly TwitterApiStatus11 Owner; | |
109 | - | |
110 | - private Dictionary<string, ApiLimit> innerDict = new Dictionary<string, ApiLimit>(); | |
111 | - | |
112 | - public EndpointLimits(TwitterApiStatus11 owner) | |
113 | - { | |
114 | - this.Owner = owner; | |
115 | - } | |
116 | - | |
117 | - public ApiLimit this[string endpoint] | |
118 | - { | |
119 | - get | |
120 | - { | |
121 | - if (this.innerDict.ContainsKey(endpoint)) | |
122 | - return this.innerDict[endpoint]; | |
123 | - | |
124 | - return null; | |
125 | - } | |
126 | - set | |
127 | - { | |
128 | - this.innerDict[endpoint] = value; | |
129 | - this.Owner.OnAccessLimitUpdated(new AccessLimitUpdatedEventArgs(endpoint)); | |
130 | - } | |
131 | - } | |
132 | - | |
133 | - public void Clear() | |
134 | - { | |
135 | - this.innerDict.Clear(); | |
136 | - this.Owner.OnAccessLimitUpdated(new AccessLimitUpdatedEventArgs(null)); | |
137 | - } | |
138 | - | |
139 | - public void AddAll(IDictionary<string, ApiLimit> resources) | |
140 | - { | |
141 | - foreach (var res in resources) | |
142 | - { | |
143 | - this.innerDict[res.Key] = res.Value; | |
144 | - } | |
145 | - | |
146 | - this.Owner.OnAccessLimitUpdated(new AccessLimitUpdatedEventArgs(null)); | |
147 | - } | |
148 | - } | |
149 | - } | |
150 | -} |
@@ -173,8 +173,6 @@ | ||
173 | 173 | this.TextProxyAddress = new System.Windows.Forms.TextBox(); |
174 | 174 | this.LabelProxyPort = new System.Windows.Forms.Label(); |
175 | 175 | this.ConnectionPanel = new System.Windows.Forms.Panel(); |
176 | - this.TwitterSearchAPIText = new System.Windows.Forms.TextBox(); | |
177 | - this.Label31 = new System.Windows.Forms.Label(); | |
178 | 176 | this.TwitterAPIText = new System.Windows.Forms.TextBox(); |
179 | 177 | this.Label8 = new System.Windows.Forms.Label(); |
180 | 178 | this.CheckUseSsl = new System.Windows.Forms.CheckBox(); |
@@ -1668,8 +1666,6 @@ | ||
1668 | 1666 | // ConnectionPanel |
1669 | 1667 | // |
1670 | 1668 | resources.ApplyResources(this.ConnectionPanel, "ConnectionPanel"); |
1671 | - this.ConnectionPanel.Controls.Add(this.TwitterSearchAPIText); | |
1672 | - this.ConnectionPanel.Controls.Add(this.Label31); | |
1673 | 1669 | this.ConnectionPanel.Controls.Add(this.TwitterAPIText); |
1674 | 1670 | this.ConnectionPanel.Controls.Add(this.Label8); |
1675 | 1671 | this.ConnectionPanel.Controls.Add(this.CheckUseSsl); |
@@ -1679,18 +1675,6 @@ | ||
1679 | 1675 | this.ConnectionPanel.Name = "ConnectionPanel"; |
1680 | 1676 | this.ToolTip1.SetToolTip(this.ConnectionPanel, resources.GetString("ConnectionPanel.ToolTip")); |
1681 | 1677 | // |
1682 | - // TwitterSearchAPIText | |
1683 | - // | |
1684 | - resources.ApplyResources(this.TwitterSearchAPIText, "TwitterSearchAPIText"); | |
1685 | - this.TwitterSearchAPIText.Name = "TwitterSearchAPIText"; | |
1686 | - this.ToolTip1.SetToolTip(this.TwitterSearchAPIText, resources.GetString("TwitterSearchAPIText.ToolTip")); | |
1687 | - // | |
1688 | - // Label31 | |
1689 | - // | |
1690 | - resources.ApplyResources(this.Label31, "Label31"); | |
1691 | - this.Label31.Name = "Label31"; | |
1692 | - this.ToolTip1.SetToolTip(this.Label31, resources.GetString("Label31.ToolTip")); | |
1693 | - // | |
1694 | 1678 | // TwitterAPIText |
1695 | 1679 | // |
1696 | 1680 | resources.ApplyResources(this.TwitterAPIText, "TwitterAPIText"); |
@@ -2801,8 +2785,6 @@ | ||
2801 | 2785 | internal System.Windows.Forms.TextBox TextProxyAddress; |
2802 | 2786 | internal System.Windows.Forms.Label LabelProxyPort; |
2803 | 2787 | internal System.Windows.Forms.Panel ConnectionPanel; |
2804 | - internal System.Windows.Forms.TextBox TwitterSearchAPIText; | |
2805 | - internal System.Windows.Forms.Label Label31; | |
2806 | 2788 | internal System.Windows.Forms.TextBox TwitterAPIText; |
2807 | 2789 | internal System.Windows.Forms.Label Label8; |
2808 | 2790 | internal System.Windows.Forms.CheckBox CheckUseSsl; |
@@ -436,7 +436,6 @@ namespace OpenTween | ||
436 | 436 | UseHashSupplement = CheckHashSupple.Checked; |
437 | 437 | PreviewEnable = CheckPreviewEnable.Checked; |
438 | 438 | TwitterApiUrl = TwitterAPIText.Text.Trim(); |
439 | - TwitterSearchApiUrl = TwitterSearchAPIText.Text.Trim(); | |
440 | 439 | switch (ReplyIconStateCombo.SelectedIndex) |
441 | 440 | { |
442 | 441 | case 0: |
@@ -818,7 +817,6 @@ namespace OpenTween | ||
818 | 817 | CheckHashSupple.Checked = UseHashSupplement; |
819 | 818 | CheckPreviewEnable.Checked = PreviewEnable; |
820 | 819 | TwitterAPIText.Text = TwitterApiUrl; |
821 | - TwitterSearchAPIText.Text = TwitterSearchApiUrl; | |
822 | 820 | switch (ReplyIconState) |
823 | 821 | { |
824 | 822 | case MyCommon.REPLY_ICONSTATE.None: |
@@ -1395,7 +1393,6 @@ namespace OpenTween | ||
1395 | 1393 | public bool UseAdditionalCount { get; set; } |
1396 | 1394 | public bool OpenUserTimeline { get; set; } |
1397 | 1395 | public string TwitterApiUrl { get; set; } |
1398 | - public string TwitterSearchApiUrl { get; set; } | |
1399 | 1396 | public string Language { get; set; } |
1400 | 1397 | |
1401 | 1398 | private void Button3_Click(object sender, EventArgs e) |
@@ -1711,7 +1708,6 @@ namespace OpenTween | ||
1711 | 1708 | //通信基底クラス初期化 |
1712 | 1709 | HttpConnection.InitializeConnection(20, ptype, padr, pport, pusr, ppw); |
1713 | 1710 | HttpTwitter.TwitterUrl = TwitterAPIText.Text.Trim(); |
1714 | - HttpTwitter.TwitterSearchUrl = TwitterSearchAPIText.Text.Trim(); | |
1715 | 1711 | tw.Initialize("", "", "", 0); |
1716 | 1712 | //this.AuthStateLabel.Text = Properties.Resources.AuthorizeButton_Click4; |
1717 | 1713 | //this.AuthUserLabel.Text = ""; |
@@ -1828,11 +1824,11 @@ namespace OpenTween | ||
1828 | 1824 | private void DisplayApiMaxCount() |
1829 | 1825 | { |
1830 | 1826 | var limit = MyCommon.TwitterApiInfo.AccessLimit; |
1831 | - if (limit != null) | |
1832 | - { | |
1833 | - LabelApiUsing.Text = string.Format(Properties.Resources.SettingAPIUse1, limit.AccessLimitCount - limit.AccessLimitRemain, limit.AccessLimitCount); | |
1834 | - } | |
1835 | - else | |
1827 | +// if (limit != null) | |
1828 | +// { | |
1829 | +// LabelApiUsing.Text = string.Format(Properties.Resources.SettingAPIUse1, limit.AccessLimitCount - limit.AccessLimitRemain, limit.AccessLimitCount); | |
1830 | +// } | |
1831 | +// else | |
1836 | 1832 | { |
1837 | 1833 | LabelApiUsing.Text = string.Format(Properties.Resources.SettingAPIUse1, "???", "???"); |
1838 | 1834 | } |
@@ -1921,7 +1917,7 @@ namespace OpenTween | ||
1921 | 1917 | { |
1922 | 1918 | if (Twitter.AccountState == MyCommon.ACCOUNT_STATE.Valid) |
1923 | 1919 | { |
1924 | - Task.Factory.StartNew(() => tw.GetInfoApi10()) //取得エラー時はinfoCountは初期状態(値:-1) | |
1920 | + Task.Factory.StartNew(() => tw.GetInfoApi()) //取得エラー時はinfoCountは初期状態(値:-1) | |
1925 | 1921 | .ContinueWith(t => |
1926 | 1922 | { |
1927 | 1923 | if (this.IsHandleCreated && !this.IsDisposed) |
@@ -1937,7 +1933,7 @@ namespace OpenTween | ||
1937 | 1933 | } |
1938 | 1934 | else |
1939 | 1935 | { |
1940 | - LabelApiUsing.Text = string.Format(Properties.Resources.SettingAPIUse1, UsingApi, limit.AccessLimitCount); | |
1936 | +// LabelApiUsing.Text = string.Format(Properties.Resources.SettingAPIUse1, UsingApi, limit.AccessLimitCount); | |
1941 | 1937 | } |
1942 | 1938 | } |
1943 | 1939 |
@@ -126,9 +126,6 @@ | ||
126 | 126 | <value>7</value> |
127 | 127 | </data> |
128 | 128 | <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> |
129 | - <data name="Label31.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms"> | |
130 | - <value>NoControl</value> | |
131 | - </data> | |
132 | 129 | <data name="btnUnread.Size" type="System.Drawing.Size, System.Drawing"> |
133 | 130 | <value>83, 25</value> |
134 | 131 | </data> |
@@ -300,9 +297,6 @@ | ||
300 | 297 | <data name="IsListsIncludeRtsCheckBox.AutoSize" type="System.Boolean, mscorlib"> |
301 | 298 | <value>True</value> |
302 | 299 | </data> |
303 | - <data name="TwitterSearchAPIText.Size" type="System.Drawing.Size, System.Drawing"> | |
304 | - <value>125, 19</value> | |
305 | - </data> | |
306 | 300 | <data name=">>btnAtSelf.Name" xml:space="preserve"> |
307 | 301 | <value>btnAtSelf</value> |
308 | 302 | </data> |
@@ -1040,9 +1034,6 @@ | ||
1040 | 1034 | <data name=">>Label64.Parent" xml:space="preserve"> |
1041 | 1035 | <value>ConnectionPanel</value> |
1042 | 1036 | </data> |
1043 | - <data name=">>TwitterSearchAPIText.ZOrder" xml:space="preserve"> | |
1044 | - <value>0</value> | |
1045 | - </data> | |
1046 | 1037 | <data name="HotkeyWin.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms"> |
1047 | 1038 | <value>NoControl</value> |
1048 | 1039 | </data> |
@@ -1223,9 +1214,6 @@ | ||
1223 | 1214 | <data name="HotkeyShift.TabIndex" type="System.Int32, mscorlib"> |
1224 | 1215 | <value>2</value> |
1225 | 1216 | </data> |
1226 | - <data name=">>Label31.Type" xml:space="preserve"> | |
1227 | - <value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |
1228 | - </data> | |
1229 | 1217 | <data name="Label52.Size" type="System.Drawing.Size, System.Drawing"> |
1230 | 1218 | <value>131, 12</value> |
1231 | 1219 | </data> |
@@ -2416,9 +2404,6 @@ | ||
2416 | 2404 | <data name="ChkNewMentionsBlink.TabIndex" type="System.Int32, mscorlib"> |
2417 | 2405 | <value>9</value> |
2418 | 2406 | </data> |
2419 | - <data name=">>TwitterSearchAPIText.Parent" xml:space="preserve"> | |
2420 | - <value>ConnectionPanel</value> | |
2421 | - </data> | |
2422 | 2407 | <data name="lblDetailBackcolor.TabIndex" type="System.Int32, mscorlib"> |
2423 | 2408 | <value>22</value> |
2424 | 2409 | </data> |
@@ -2500,9 +2485,6 @@ | ||
2500 | 2485 | <data name=">>Label57.ZOrder" xml:space="preserve"> |
2501 | 2486 | <value>5</value> |
2502 | 2487 | </data> |
2503 | - <data name="TwitterSearchAPIText.ToolTip" xml:space="preserve"> | |
2504 | - <value /> | |
2505 | - </data> | |
2506 | 2488 | <data name=">>UserTimelinePeriod.Type" xml:space="preserve"> |
2507 | 2489 | <value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
2508 | 2490 | </data> |
@@ -3463,9 +3445,6 @@ | ||
3463 | 3445 | <data name=">>btnInputBackcolor.ZOrder" xml:space="preserve"> |
3464 | 3446 | <value>10</value> |
3465 | 3447 | </data> |
3466 | - <data name=">>Label31.Name" xml:space="preserve"> | |
3467 | - <value>Label31</value> | |
3468 | - </data> | |
3469 | 3448 | <data name="Label18.ToolTip" xml:space="preserve"> |
3470 | 3449 | <value /> |
3471 | 3450 | </data> |
@@ -3937,9 +3916,6 @@ | ||
3937 | 3916 | <data name="CooperatePanel.TabIndex" type="System.Int32, mscorlib"> |
3938 | 3917 | <value>12</value> |
3939 | 3918 | </data> |
3940 | - <data name=">>Label31.ZOrder" xml:space="preserve"> | |
3941 | - <value>1</value> | |
3942 | - </data> | |
3943 | 3919 | <data name=">>CheckAlwaysTop.ZOrder" xml:space="preserve"> |
3944 | 3920 | <value>10</value> |
3945 | 3921 | </data> |
@@ -4147,18 +4123,12 @@ | ||
4147 | 4123 | <data name="Label28.Text" xml:space="preserve"> |
4148 | 4124 | <value>初回の更新</value> |
4149 | 4125 | </data> |
4150 | - <data name="TwitterSearchAPIText.TabIndex" type="System.Int32, mscorlib"> | |
4151 | - <value>7</value> | |
4152 | - </data> | |
4153 | 4126 | <data name="GroupBox2.ToolTip" xml:space="preserve"> |
4154 | 4127 | <value /> |
4155 | 4128 | </data> |
4156 | 4129 | <data name="Label67.Location" type="System.Drawing.Point, System.Drawing"> |
4157 | 4130 | <value>22, 24</value> |
4158 | 4131 | </data> |
4159 | - <data name=">>TwitterSearchAPIText.Type" xml:space="preserve"> | |
4160 | - <value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |
4161 | - </data> | |
4162 | 4132 | <data name="lblTarget.Text" xml:space="preserve"> |
4163 | 4133 | <value>This is sample.</value> |
4164 | 4134 | </data> |
@@ -4396,9 +4366,6 @@ | ||
4396 | 4366 | <data name="ComboBoxTranslateLanguage.Items48" xml:space="preserve"> |
4397 | 4367 | <value>French (Belgium)</value> |
4398 | 4368 | </data> |
4399 | - <data name="TwitterSearchAPIText.Location" type="System.Drawing.Point, System.Drawing"> | |
4400 | - <value>262, 125</value> | |
4401 | - </data> | |
4402 | 4369 | <data name=">>ButtonApiCalc.Name" xml:space="preserve"> |
4403 | 4370 | <value>ButtonApiCalc</value> |
4404 | 4371 | </data> |
@@ -4639,9 +4606,6 @@ | ||
4639 | 4606 | <data name="CheckBalloonLimit.Text" xml:space="preserve"> |
4640 | 4607 | <value>画面最小化・アイコン時のみバルーンを表示する</value> |
4641 | 4608 | </data> |
4642 | - <data name="Label31.Size" type="System.Drawing.Size, System.Drawing"> | |
4643 | - <value>228, 12</value> | |
4644 | - </data> | |
4645 | 4609 | <data name="Label46.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms"> |
4646 | 4610 | <value>NoControl</value> |
4647 | 4611 | </data> |
@@ -5184,9 +5148,6 @@ Growl.CoreLibrary.DLL</value> | ||
5184 | 5148 | <data name=">>Label59.Name" xml:space="preserve"> |
5185 | 5149 | <value>Label59</value> |
5186 | 5150 | </data> |
5187 | - <data name="Label31.Text" xml:space="preserve"> | |
5188 | - <value>Twitter SearchAPI URL (search.twitter.com)</value> | |
5189 | - </data> | |
5190 | 5151 | <data name=">>Label7.Parent" xml:space="preserve"> |
5191 | 5152 | <value>GetPeriodPanel</value> |
5192 | 5153 | </data> |
@@ -6168,9 +6129,6 @@ Growl.CoreLibrary.DLL</value> | ||
6168 | 6129 | <data name="CheckMinimizeToTray.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms"> |
6169 | 6130 | <value>NoControl</value> |
6170 | 6131 | </data> |
6171 | - <data name=">>Label31.Parent" xml:space="preserve"> | |
6172 | - <value>ConnectionPanel</value> | |
6173 | - </data> | |
6174 | 6132 | <data name=">>Label62.Type" xml:space="preserve"> |
6175 | 6133 | <value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
6176 | 6134 | </data> |
@@ -6474,9 +6432,6 @@ Growl.CoreLibrary.DLL</value> | ||
6474 | 6432 | <data name="btnFav.ToolTip" xml:space="preserve"> |
6475 | 6433 | <value /> |
6476 | 6434 | </data> |
6477 | - <data name="TwitterSearchAPIText.Visible" type="System.Boolean, mscorlib"> | |
6478 | - <value>False</value> | |
6479 | - </data> | |
6480 | 6435 | <data name="Label81.ToolTip" xml:space="preserve"> |
6481 | 6436 | <value /> |
6482 | 6437 | </data> |
@@ -6771,9 +6726,6 @@ Growl.CoreLibrary.DLL</value> | ||
6771 | 6726 | <data name=">>BrowserPathText.Type" xml:space="preserve"> |
6772 | 6727 | <value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
6773 | 6728 | </data> |
6774 | - <data name="Label31.AutoSize" type="System.Boolean, mscorlib"> | |
6775 | - <value>True</value> | |
6776 | - </data> | |
6777 | 6729 | <data name="Cancel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms"> |
6778 | 6730 | <value>NoControl</value> |
6779 | 6731 | </data> |
@@ -6912,9 +6864,6 @@ Growl.CoreLibrary.DLL</value> | ||
6912 | 6864 | <data name=">>FollowCheckBox.Parent" xml:space="preserve"> |
6913 | 6865 | <value>GroupBox2</value> |
6914 | 6866 | </data> |
6915 | - <data name="Label31.TabIndex" type="System.Int32, mscorlib"> | |
6916 | - <value>6</value> | |
6917 | - </data> | |
6918 | 6867 | <data name=">>TextProxyUser.Name" xml:space="preserve"> |
6919 | 6868 | <value>TextProxyUser</value> |
6920 | 6869 | </data> |
@@ -7407,9 +7356,6 @@ Growl.CoreLibrary.DLL</value> | ||
7407 | 7356 | <data name="TextCountApi.TabIndex" type="System.Int32, mscorlib"> |
7408 | 7357 | <value>1</value> |
7409 | 7358 | </data> |
7410 | - <data name="Label31.ToolTip" xml:space="preserve"> | |
7411 | - <value /> | |
7412 | - </data> | |
7413 | 7359 | <data name=">>RadioProxyIE.ZOrder" xml:space="preserve"> |
7414 | 7360 | <value>4</value> |
7415 | 7361 | </data> |
@@ -8007,9 +7953,6 @@ Growl.CoreLibrary.DLL</value> | ||
8007 | 7953 | <data name=">>Label19.Parent" xml:space="preserve"> |
8008 | 7954 | <value>GetCountPanel</value> |
8009 | 7955 | </data> |
8010 | - <data name="Label31.Visible" type="System.Boolean, mscorlib"> | |
8011 | - <value>False</value> | |
8012 | - </data> | |
8013 | 7956 | <data name="IsPreviewFoursquareCheckBox.Text" xml:space="preserve"> |
8014 | 7957 | <value>FoursquareのURLからプレビューを表示する(非常に重くなります)</value> |
8015 | 7958 | </data> |
@@ -8019,9 +7962,6 @@ Growl.CoreLibrary.DLL</value> | ||
8019 | 7962 | <data name="CheckAlwaysTop.ToolTip" xml:space="preserve"> |
8020 | 7963 | <value /> |
8021 | 7964 | </data> |
8022 | - <data name="TwitterSearchAPIText.Text" xml:space="preserve"> | |
8023 | - <value>search.twitter.com</value> | |
8024 | - </data> | |
8025 | 7965 | <data name=">>lblListBackcolor.Type" xml:space="preserve"> |
8026 | 7966 | <value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
8027 | 7967 | </data> |
@@ -8109,9 +8049,6 @@ Growl.CoreLibrary.DLL</value> | ||
8109 | 8049 | <data name=">>CheckReadOldPosts.Name" xml:space="preserve"> |
8110 | 8050 | <value>CheckReadOldPosts</value> |
8111 | 8051 | </data> |
8112 | - <data name=">>TwitterSearchAPIText.Name" xml:space="preserve"> | |
8113 | - <value>TwitterSearchAPIText</value> | |
8114 | - </data> | |
8115 | 8052 | <data name="lblAtSelf.ToolTip" xml:space="preserve"> |
8116 | 8053 | <value /> |
8117 | 8054 | </data> |
@@ -8442,9 +8379,6 @@ Growl.CoreLibrary.DLL</value> | ||
8442 | 8379 | <data name=">>CheckListMemberAddedEvent.Type" xml:space="preserve"> |
8443 | 8380 | <value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
8444 | 8381 | </data> |
8445 | - <data name="Label31.Location" type="System.Drawing.Point, System.Drawing"> | |
8446 | - <value>22, 128</value> | |
8447 | - </data> | |
8448 | 8382 | <data name="ShortenTcoCheck.Location" type="System.Drawing.Point, System.Drawing"> |
8449 | 8383 | <value>40, 90</value> |
8450 | 8384 | </data> |
@@ -616,15 +616,6 @@ | ||
616 | 616 | <data name="LabelProxyPort.Text" xml:space="preserve"> |
617 | 617 | <value>端口(&P)</value> |
618 | 618 | </data> |
619 | - <data name="TwitterSearchAPIText.Size" type="System.Drawing.Size, System.Drawing"> | |
620 | - <value>143, 19</value> | |
621 | - </data> | |
622 | - <data name="Label31.Size" type="System.Drawing.Size, System.Drawing"> | |
623 | - <value>192, 12</value> | |
624 | - </data> | |
625 | - <data name="Label31.Text" xml:space="preserve"> | |
626 | - <value>Search API URL (search.twitter.com)</value> | |
627 | - </data> | |
628 | 619 | <data name="TwitterAPIText.Size" type="System.Drawing.Size, System.Drawing"> |
629 | 620 | <value>143, 19</value> |
630 | 621 | </data> |
@@ -35,15 +35,6 @@ namespace OpenTween | ||
35 | 35 | { |
36 | 36 | public class HttpTwitter : ICloneable |
37 | 37 | { |
38 | - /// <summary> | |
39 | - /// API v1.1 を有効にする否か | |
40 | - /// </summary> | |
41 | - /// <remarks> | |
42 | - /// 旧APIが使用出来なくなったら消す予定。 | |
43 | - /// 静的フィールドとしているのは TwitterUserstream クラスが Clone メソッドを使用しているため | |
44 | - /// </remarks> | |
45 | - public static bool API11Enabled { get; set; } | |
46 | - | |
47 | 38 | //OAuth関連 |
48 | 39 | ///<summary> |
49 | 40 | ///OAuthのアクセストークン取得先URI |
@@ -74,11 +65,6 @@ namespace OpenTween | ||
74 | 65 | private static string tks = ""; |
75 | 66 | private static string un = ""; |
76 | 67 | |
77 | - static HttpTwitter() | |
78 | - { | |
79 | - HttpTwitter.API11Enabled = true; | |
80 | - } | |
81 | - | |
82 | 68 | public void Initialize(string accessToken, |
83 | 69 | string accessTokenSecret, |
84 | 70 | string username, |
@@ -200,7 +186,7 @@ namespace OpenTween | ||
200 | 186 | //if (AppendSettingDialog.Instance.ShortenTco && AppendSettingDialog.Instance.UrlConvertAuto) param.Add("wrap_links", "true") |
201 | 187 | |
202 | 188 | return httpCon.GetContent(PostMethod, |
203 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/update.json" : "/1/statuses/update.json"), | |
189 | + this.CreateTwitterUri("/1.1/statuses/update.json"), | |
204 | 190 | param, |
205 | 191 | ref content, |
206 | 192 | null, |
@@ -220,12 +206,12 @@ namespace OpenTween | ||
220 | 206 | binary.Add(new KeyValuePair<string, FileInfo>("media[]", mediaFile)); |
221 | 207 | |
222 | 208 | return httpCon.GetContent(PostMethod, |
223 | - HttpTwitter.API11Enabled ? CreateTwitterUri("/1.1/statuses/update_with_media.json") : new Uri("https://upload.twitter.com/1/statuses/update_with_media.json"), | |
209 | + this.CreateTwitterUri("/1.1/statuses/update_with_media.json"), | |
224 | 210 | param, |
225 | 211 | binary, |
226 | 212 | ref content, |
227 | 213 | this.CreateRetelimitHeadersDict(), |
228 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/update_with_media") : GetApiCallback); | |
214 | + this.CreateApiCalllback("/statuses/update_with_media")); | |
229 | 215 | } |
230 | 216 | |
231 | 217 | public HttpStatusCode DestroyStatus(long id) |
@@ -233,7 +219,7 @@ namespace OpenTween | ||
233 | 219 | string content = null; |
234 | 220 | |
235 | 221 | return httpCon.GetContent(PostMethod, |
236 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/destroy/" + id + ".json" : "/1/statuses/destroy/" + id + ".json"), | |
222 | + this.CreateTwitterUri("/1.1/statuses/destroy/" + id + ".json"), | |
237 | 223 | null, |
238 | 224 | ref content, |
239 | 225 | null, |
@@ -248,7 +234,7 @@ namespace OpenTween | ||
248 | 234 | //if (AppendSettingDialog.Instance.ShortenTco && AppendSettingDialog.Instance.UrlConvertAuto) param.Add("wrap_links", "true") |
249 | 235 | |
250 | 236 | return httpCon.GetContent(PostMethod, |
251 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/direct_messages/new.json" : "/1/direct_messages/new.json"), | |
237 | + this.CreateTwitterUri("/1.1/direct_messages/new.json"), | |
252 | 238 | param, |
253 | 239 | ref content, |
254 | 240 | null, |
@@ -260,11 +246,10 @@ namespace OpenTween | ||
260 | 246 | string content = null; |
261 | 247 | |
262 | 248 | var param = new Dictionary<string, string>(); |
263 | - if (HttpTwitter.API11Enabled) | |
264 | - param.Add("id", id.ToString()); | |
249 | + param.Add("id", id.ToString()); | |
265 | 250 | |
266 | 251 | return httpCon.GetContent(PostMethod, |
267 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/direct_messages/destroy.json" : "/1/direct_messages/destroy/" + id + ".json"), | |
252 | + this.CreateTwitterUri("/1.1/direct_messages/destroy.json"), | |
268 | 253 | param, |
269 | 254 | ref content, |
270 | 255 | null, |
@@ -277,7 +262,7 @@ namespace OpenTween | ||
277 | 262 | param.Add("include_entities", "true"); |
278 | 263 | |
279 | 264 | return httpCon.GetContent(PostMethod, |
280 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/retweet/" + id + ".json" : "/1/statuses/retweet/" + id + ".json"), | |
265 | + this.CreateTwitterUri("/1.1/statuses/retweet/" + id + ".json"), | |
281 | 266 | param, |
282 | 267 | ref content, |
283 | 268 | null, |
@@ -290,11 +275,11 @@ namespace OpenTween | ||
290 | 275 | param.Add("screen_name", screenName); |
291 | 276 | param.Add("include_entities", "true"); |
292 | 277 | return httpCon.GetContent(GetMethod, |
293 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/users/show.json" : "/1/users/show.json"), | |
278 | + this.CreateTwitterUri("/1.1/users/show.json"), | |
294 | 279 | param, |
295 | 280 | ref content, |
296 | 281 | this.CreateRetelimitHeadersDict(), |
297 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/users/show/:id") : GetApiCallback); | |
282 | + this.CreateApiCalllback("/users/show/:id")); | |
298 | 283 | } |
299 | 284 | |
300 | 285 | public HttpStatusCode CreateFriendships(string screenName, ref string content) |
@@ -303,7 +288,7 @@ namespace OpenTween | ||
303 | 288 | param.Add("screen_name", screenName); |
304 | 289 | |
305 | 290 | return httpCon.GetContent(PostMethod, |
306 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/friendships/create.json" : "/1/friendships/create.json"), | |
291 | + this.CreateTwitterUri("/1.1/friendships/create.json"), | |
307 | 292 | param, |
308 | 293 | ref content, |
309 | 294 | null, |
@@ -316,7 +301,7 @@ namespace OpenTween | ||
316 | 301 | param.Add("screen_name", screenName); |
317 | 302 | |
318 | 303 | return httpCon.GetContent(PostMethod, |
319 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/friendships/destroy.json" : "/1/friendships/destroy.json"), | |
304 | + this.CreateTwitterUri("/1.1/friendships/destroy.json"), | |
320 | 305 | param, |
321 | 306 | ref content, |
322 | 307 | null, |
@@ -329,7 +314,7 @@ namespace OpenTween | ||
329 | 314 | param.Add("screen_name", screenName); |
330 | 315 | |
331 | 316 | return httpCon.GetContent(PostMethod, |
332 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/blocks/create.json" : "/1/blocks/create.json"), | |
317 | + this.CreateTwitterUri("/1.1/blocks/create.json"), | |
333 | 318 | param, |
334 | 319 | ref content, |
335 | 320 | null, |
@@ -342,7 +327,7 @@ namespace OpenTween | ||
342 | 327 | param.Add("screen_name", screenName); |
343 | 328 | |
344 | 329 | return httpCon.GetContent(PostMethod, |
345 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/blocks/destroy.json" : "/1/blocks/destroy.json"), | |
330 | + this.CreateTwitterUri("/1.1/blocks/destroy.json"), | |
346 | 331 | param, |
347 | 332 | ref content, |
348 | 333 | null, |
@@ -355,7 +340,7 @@ namespace OpenTween | ||
355 | 340 | param.Add("screen_name", screenName); |
356 | 341 | |
357 | 342 | return httpCon.GetContent(PostMethod, |
358 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/users/report_spam.json" : "/1/report_spam.json"), | |
343 | + this.CreateTwitterUri("/1.1/users/report_spam.json"), | |
359 | 344 | param, |
360 | 345 | ref content, |
361 | 346 | null, |
@@ -369,11 +354,11 @@ namespace OpenTween | ||
369 | 354 | param.Add("target_screen_name", targetScreenName); |
370 | 355 | |
371 | 356 | return httpCon.GetContent(GetMethod, |
372 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/friendships/show.json" : "/1/friendships/show.json"), | |
357 | + this.CreateTwitterUri("/1.1/friendships/show.json"), | |
373 | 358 | param, |
374 | 359 | ref content, |
375 | 360 | this.CreateRetelimitHeadersDict(), |
376 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/friendships/show") : GetApiCallback); | |
361 | + this.CreateApiCalllback("/friendships/show")); | |
377 | 362 | } |
378 | 363 | |
379 | 364 | public HttpStatusCode ShowStatuses(long id, ref string content) |
@@ -381,21 +366,20 @@ namespace OpenTween | ||
381 | 366 | Dictionary<string, string> param = new Dictionary<string, string>(); |
382 | 367 | param.Add("include_entities", "true"); |
383 | 368 | return httpCon.GetContent(GetMethod, |
384 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/show/" + id + ".json" : "/1/statuses/show/" + id + ".json"), | |
369 | + this.CreateTwitterUri("/1.1/statuses/show/" + id + ".json"), | |
385 | 370 | param, |
386 | 371 | ref content, |
387 | 372 | this.CreateRetelimitHeadersDict(), |
388 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/show/:id") : GetApiCallback); | |
373 | + this.CreateApiCalllback("/statuses/show/:id")); | |
389 | 374 | } |
390 | 375 | |
391 | 376 | public HttpStatusCode CreateFavorites(long id, ref string content) |
392 | 377 | { |
393 | 378 | var param = new Dictionary<string, string>(); |
394 | - if (HttpTwitter.API11Enabled) | |
395 | - param.Add("id", id.ToString()); | |
379 | + param.Add("id", id.ToString()); | |
396 | 380 | |
397 | 381 | return httpCon.GetContent(PostMethod, |
398 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/favorites/create.json" : "/1/favorites/create/" + id + ".json"), | |
382 | + this.CreateTwitterUri("/1.1/favorites/create.json"), | |
399 | 383 | param, |
400 | 384 | ref content, |
401 | 385 | null, |
@@ -405,11 +389,10 @@ namespace OpenTween | ||
405 | 389 | public HttpStatusCode DestroyFavorites(long id, ref string content) |
406 | 390 | { |
407 | 391 | var param = new Dictionary<string, string>(); |
408 | - if (HttpTwitter.API11Enabled) | |
409 | - param.Add("id", id.ToString()); | |
392 | + param.Add("id", id.ToString()); | |
410 | 393 | |
411 | 394 | return httpCon.GetContent(PostMethod, |
412 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/favorites/destroy.json" : "/1/favorites/destroy/" + id + ".json"), | |
395 | + this.CreateTwitterUri("/1.1/favorites/destroy.json"), | |
413 | 396 | param, |
414 | 397 | ref content, |
415 | 398 | null, |
@@ -429,11 +412,11 @@ namespace OpenTween | ||
429 | 412 | param.Add("include_entities", "true"); |
430 | 413 | |
431 | 414 | return httpCon.GetContent(GetMethod, |
432 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/home_timeline.json" : "/1/statuses/home_timeline.json"), | |
415 | + this.CreateTwitterUri("/1.1/statuses/home_timeline.json"), | |
433 | 416 | param, |
434 | 417 | ref content, |
435 | 418 | this.CreateRetelimitHeadersDict(), |
436 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/home_timeline") : GetApiCallback); | |
419 | + this.CreateApiCalllback("/statuses/home_timeline")); | |
437 | 420 | } |
438 | 421 | |
439 | 422 | public HttpStatusCode UserTimeline(long? user_id, string screen_name, int? count, long? max_id, long? since_id, ref string content) |
@@ -458,33 +441,11 @@ namespace OpenTween | ||
458 | 441 | param.Add("include_entities", "true"); |
459 | 442 | |
460 | 443 | return httpCon.GetContent(GetMethod, |
461 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/user_timeline.json" : "/1/statuses/user_timeline.json"), | |
462 | - param, | |
463 | - ref content, | |
464 | - this.CreateRetelimitHeadersDict(), | |
465 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/user_timeline") : GetApiCallback); | |
466 | - } | |
467 | - | |
468 | - public HttpStatusCode PublicTimeline(int? count, long? max_id, long? since_id, ref string content) | |
469 | - { | |
470 | - Dictionary<string, string> param = new Dictionary<string, string>(); | |
471 | - if (count != null) | |
472 | - param.Add("count", count.ToString()); | |
473 | - if (max_id != null) | |
474 | - param.Add("max_id", max_id.ToString()); | |
475 | - if (since_id != null) | |
476 | - param.Add("since_id", since_id.ToString()); | |
477 | - | |
478 | - param.Add("include_entities", "true"); | |
479 | - | |
480 | - // TODO: API v1.1 に存在しない API (旧 API で代替) | |
481 | - | |
482 | - return httpCon.GetContent(GetMethod, | |
483 | - CreateTwitterUri("/1/statuses/public_timeline.json"), | |
444 | + this.CreateTwitterUri("/1.1/statuses/user_timeline.json"), | |
484 | 445 | param, |
485 | 446 | ref content, |
486 | 447 | this.CreateRetelimitHeadersDict(), |
487 | - GetApiCallback); | |
448 | + this.CreateApiCalllback("/statuses/user_timeline")); | |
488 | 449 | } |
489 | 450 | |
490 | 451 | public HttpStatusCode Mentions(int? count, long? max_id, long? since_id, ref string content) |
@@ -500,11 +461,11 @@ namespace OpenTween | ||
500 | 461 | param.Add("include_entities", "true"); |
501 | 462 | |
502 | 463 | return httpCon.GetContent(GetMethod, |
503 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/mentions_timeline.json" : "/1/statuses/mentions.json"), | |
464 | + this.CreateTwitterUri("/1.1/statuses/mentions_timeline.json"), | |
504 | 465 | param, |
505 | 466 | ref content, |
506 | 467 | this.CreateRetelimitHeadersDict(), |
507 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/mentions_timeline") : GetApiCallback); | |
468 | + this.CreateApiCalllback("/statuses/mentions_timeline")); | |
508 | 469 | } |
509 | 470 | |
510 | 471 | public HttpStatusCode DirectMessages(int? count, long? max_id, long? since_id, ref string content) |
@@ -519,11 +480,11 @@ namespace OpenTween | ||
519 | 480 | param.Add("include_entities", "true"); |
520 | 481 | |
521 | 482 | return httpCon.GetContent(GetMethod, |
522 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/direct_messages.json" : "/1/direct_messages.json"), | |
483 | + this.CreateTwitterUri("/1.1/direct_messages.json"), | |
523 | 484 | param, |
524 | 485 | ref content, |
525 | 486 | this.CreateRetelimitHeadersDict(), |
526 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/direct_messages") : GetApiCallback); | |
487 | + this.CreateApiCalllback("/direct_messages")); | |
527 | 488 | } |
528 | 489 | |
529 | 490 | public HttpStatusCode DirectMessagesSent(int? count, long? max_id, long? since_id, ref string content) |
@@ -538,11 +499,11 @@ namespace OpenTween | ||
538 | 499 | param.Add("include_entities", "true"); |
539 | 500 | |
540 | 501 | return httpCon.GetContent(GetMethod, |
541 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/direct_messages/sent.json" : "/1/direct_messages/sent.json"), | |
502 | + this.CreateTwitterUri("/1.1/direct_messages/sent.json"), | |
542 | 503 | param, |
543 | 504 | ref content, |
544 | 505 | this.CreateRetelimitHeadersDict(), |
545 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/direct_messages/sent") : GetApiCallback); | |
506 | + this.CreateApiCalllback("/direct_messages/sent")); | |
546 | 507 | } |
547 | 508 | |
548 | 509 | public HttpStatusCode Favorites(int? count, int? page, ref string content) |
@@ -558,54 +519,11 @@ namespace OpenTween | ||
558 | 519 | param.Add("include_entities", "true"); |
559 | 520 | |
560 | 521 | return httpCon.GetContent(GetMethod, |
561 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/favorites/list.json" : "/1/favorites.json"), | |
522 | + this.CreateTwitterUri("/1.1/favorites/list.json"), | |
562 | 523 | param, |
563 | 524 | ref content, |
564 | 525 | this.CreateRetelimitHeadersDict(), |
565 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/favorites/list") : GetApiCallback); | |
566 | - } | |
567 | - | |
568 | - public HttpStatusCode PhoenixSearch(string querystr, ref string content) | |
569 | - { | |
570 | - Dictionary<string, string> param = new Dictionary<string, string>(); | |
571 | - string[] tmp; | |
572 | - string[] paramstr; | |
573 | - if (string.IsNullOrEmpty(querystr)) return HttpStatusCode.BadRequest; | |
574 | - | |
575 | - tmp = querystr.Split(new char[] {'?', '&'}, StringSplitOptions.RemoveEmptyEntries); | |
576 | - foreach (string tmp2 in tmp) | |
577 | - { | |
578 | - paramstr = tmp2.Split(new char[] {'='}); | |
579 | - param.Add(paramstr[0], paramstr[1]); | |
580 | - } | |
581 | - | |
582 | - return httpConVar.GetContent(GetMethod, | |
583 | - CreateTwitterUri("/phoenix_search.phoenix"), | |
584 | - param, | |
585 | - out content, | |
586 | - null, | |
587 | - MyCommon.GetAssemblyName()); | |
588 | - } | |
589 | - | |
590 | - public HttpStatusCode PhoenixSearch(string words, string lang, int? rpp, int? page, long? sinceId, ref string content) | |
591 | - { | |
592 | - Dictionary<string, string> param = new Dictionary<string, string>(); | |
593 | - if (!string.IsNullOrEmpty(words)) param.Add("q", words); | |
594 | - param.Add("include_entities", "1"); | |
595 | - param.Add("contributor_details", "true"); | |
596 | - if (!string.IsNullOrEmpty(lang)) param.Add("lang", lang); | |
597 | - if (rpp != null) param.Add("rpp", rpp.ToString()); | |
598 | - if (page != null) param.Add("page", page.ToString()); | |
599 | - if (sinceId != null) param.Add("since_id", sinceId.ToString()); | |
600 | - | |
601 | - if (param.Count == 0) return HttpStatusCode.BadRequest; | |
602 | - | |
603 | - return httpConVar.GetContent(GetMethod, | |
604 | - CreateTwitterUri("/phoenix_search.phoenix"), | |
605 | - param, | |
606 | - out content, | |
607 | - null, | |
608 | - MyCommon.GetAssemblyName()); | |
526 | + this.CreateApiCalllback("/favorites/list")); | |
609 | 527 | } |
610 | 528 | |
611 | 529 | public HttpStatusCode Search(string words, string lang, int? count, long? maxId, long? sinceId, ref string content) |
@@ -613,7 +531,7 @@ namespace OpenTween | ||
613 | 531 | Dictionary<string, string> param = new Dictionary<string, string>(); |
614 | 532 | if (!string.IsNullOrEmpty(words)) param.Add("q", words); |
615 | 533 | if (!string.IsNullOrEmpty(lang)) param.Add("lang", lang); |
616 | - if (count != null) param.Add(HttpTwitter.API11Enabled ? "count" : "rpp", count.ToString()); | |
534 | + if (count != null) param.Add("count", count.ToString()); | |
617 | 535 | if (maxId != null) param.Add("max_id", maxId.ToString()); |
618 | 536 | if (sinceId != null) param.Add("since_id", sinceId.ToString()); |
619 | 537 |
@@ -622,21 +540,21 @@ namespace OpenTween | ||
622 | 540 | param.Add("result_type", "recent"); |
623 | 541 | param.Add("include_entities", "true"); |
624 | 542 | return httpCon.GetContent(GetMethod, |
625 | - HttpTwitter.API11Enabled ? this.CreateTwitterUri("/1.1/search/tweets.json") : this.CreateTwitterSearchUri("/search.json"), | |
543 | + this.CreateTwitterUri("/1.1/search/tweets.json"), | |
626 | 544 | param, |
627 | 545 | ref content, |
628 | 546 | this.CreateRetelimitHeadersDict(), |
629 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/search/tweets") : GetApiCallback); | |
547 | + this.CreateApiCalllback("/search/tweets")); | |
630 | 548 | } |
631 | 549 | |
632 | 550 | public HttpStatusCode SavedSearches(ref string content) |
633 | 551 | { |
634 | 552 | return httpCon.GetContent(GetMethod, |
635 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/saved_searches/list.json" : "/1/saved_searches.json"), | |
553 | + this.CreateTwitterUri("/1.1/saved_searches/list.json"), | |
636 | 554 | null, |
637 | 555 | ref content, |
638 | 556 | this.CreateRetelimitHeadersDict(), |
639 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/saved_searches/list") : GetApiCallback); | |
557 | + this.CreateApiCalllback("/saved_searches/list")); | |
640 | 558 | } |
641 | 559 | |
642 | 560 | public HttpStatusCode FollowerIds(long cursor, ref string content) |
@@ -645,48 +563,45 @@ namespace OpenTween | ||
645 | 563 | param.Add("cursor", cursor.ToString()); |
646 | 564 | |
647 | 565 | return httpCon.GetContent(GetMethod, |
648 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/followers/ids.json" : "/1/followers/ids.json"), | |
566 | + this.CreateTwitterUri("/1.1/followers/ids.json"), | |
649 | 567 | param, |
650 | 568 | ref content, |
651 | 569 | this.CreateRetelimitHeadersDict(), |
652 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/followers/ids") : GetApiCallback); | |
570 | + this.CreateApiCalllback("/followers/ids")); | |
653 | 571 | } |
654 | 572 | |
655 | 573 | public HttpStatusCode NoRetweetIds(ref string content) |
656 | 574 | { |
657 | 575 | return httpCon.GetContent(GetMethod, |
658 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/friendships/no_retweets/ids.json" : "/1/friendships/no_retweet_ids.json"), | |
576 | + this.CreateTwitterUri("/1.1/friendships/no_retweets/ids.json"), | |
659 | 577 | null, |
660 | 578 | ref content, |
661 | 579 | this.CreateRetelimitHeadersDict(), |
662 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/friendships/no_retweets/ids") : GetApiCallback); | |
580 | + this.CreateApiCalllback("/friendships/no_retweets/ids")); | |
663 | 581 | } |
664 | 582 | |
665 | 583 | public HttpStatusCode RateLimitStatus(ref string content) |
666 | 584 | { |
667 | 585 | return httpCon.GetContent(GetMethod, |
668 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/application/rate_limit_status.json" : "/1/account/rate_limit_status.json"), | |
586 | + this.CreateTwitterUri("/1.1/application/rate_limit_status.json"), | |
669 | 587 | null, |
670 | 588 | ref content, |
671 | 589 | this.CreateRetelimitHeadersDict(), |
672 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/application/rate_limit_status") : GetApiCallback); | |
590 | + this.CreateApiCalllback("/application/rate_limit_status")); | |
673 | 591 | } |
674 | 592 | |
675 | 593 | #region Lists |
676 | - public HttpStatusCode GetLists(string user, long? cursor, ref string content) | |
594 | + public HttpStatusCode GetLists(string user, ref string content) | |
677 | 595 | { |
678 | 596 | Dictionary<string, string> param = new Dictionary<string, string>(); |
679 | 597 | param.Add("screen_name", user); |
680 | 598 | |
681 | - if (cursor != null) | |
682 | - param.Add("cursor", cursor.Value.ToString()); // API v1 | |
683 | - | |
684 | 599 | return httpCon.GetContent(GetMethod, |
685 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/list.json" : "/1/lists.json"), | |
600 | + this.CreateTwitterUri("/1.1/lists/list.json"), | |
686 | 601 | param, |
687 | 602 | ref content, |
688 | 603 | this.CreateRetelimitHeadersDict(), |
689 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/list") : GetApiCallback); | |
604 | + this.CreateApiCalllback("/lists/list")); | |
690 | 605 | } |
691 | 606 | |
692 | 607 | public HttpStatusCode UpdateListID(string user, string list_id, string name, Boolean isPrivate, string description, ref string content) |
@@ -703,7 +618,7 @@ namespace OpenTween | ||
703 | 618 | if (description != null) param.Add("description", description); |
704 | 619 | |
705 | 620 | return httpCon.GetContent(PostMethod, |
706 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/update.json" : "/1/lists/update.json"), | |
621 | + this.CreateTwitterUri("/1.1/lists/update.json"), | |
707 | 622 | param, |
708 | 623 | ref content, |
709 | 624 | null, |
@@ -717,27 +632,24 @@ namespace OpenTween | ||
717 | 632 | param.Add("list_id", list_id); |
718 | 633 | |
719 | 634 | return httpCon.GetContent(PostMethod, |
720 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/destroy.json" : "/1/lists/destroy.json"), | |
635 | + this.CreateTwitterUri("/1.1/lists/destroy.json"), | |
721 | 636 | param, |
722 | 637 | ref content, |
723 | 638 | null, |
724 | 639 | null); |
725 | 640 | } |
726 | 641 | |
727 | - public HttpStatusCode GetListsSubscriptions(string user, long? cursor, ref string content) | |
642 | + public HttpStatusCode GetListsSubscriptions(string user, ref string content) | |
728 | 643 | { |
729 | 644 | Dictionary<string, string> param = new Dictionary<string, string>(); |
730 | 645 | param.Add("screen_name", user); |
731 | 646 | |
732 | - if (cursor != null) | |
733 | - param.Add("cursor", cursor.Value.ToString()); // API v1 | |
734 | - | |
735 | 647 | return httpCon.GetContent(GetMethod, |
736 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/subscriptions.json" : "/1/lists/subscriptions.json"), | |
648 | + this.CreateTwitterUri("/1.1/lists/subscriptions.json"), | |
737 | 649 | param, |
738 | 650 | ref content, |
739 | 651 | this.CreateRetelimitHeadersDict(), |
740 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/subscriptions") : GetApiCallback); | |
652 | + this.CreateApiCalllback("/lists/subscriptions")); | |
741 | 653 | } |
742 | 654 | |
743 | 655 | public HttpStatusCode GetListsStatuses(long userId, long list_id, int? per_page, long? max_id, long? since_id, Boolean isRTinclude, ref string content) |
@@ -748,7 +660,7 @@ namespace OpenTween | ||
748 | 660 | param.Add("list_id", list_id.ToString()); |
749 | 661 | param.Add("include_rts", isRTinclude ? "true" : "false"); |
750 | 662 | if (per_page != null) |
751 | - param.Add(HttpTwitter.API11Enabled ? "count" : "per_page", per_page.ToString()); | |
663 | + param.Add("count", per_page.ToString()); | |
752 | 664 | if (max_id != null) |
753 | 665 | param.Add("max_id", max_id.ToString()); |
754 | 666 | if (since_id != null) |
@@ -756,11 +668,11 @@ namespace OpenTween | ||
756 | 668 | param.Add("include_entities", "true"); |
757 | 669 | |
758 | 670 | return httpCon.GetContent(GetMethod, |
759 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/statuses.json" : "/1/lists/statuses.json"), | |
671 | + this.CreateTwitterUri("/1.1/lists/statuses.json"), | |
760 | 672 | param, |
761 | 673 | ref content, |
762 | 674 | this.CreateRetelimitHeadersDict(), |
763 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/statuses") : GetApiCallback); | |
675 | + this.CreateApiCalllback("/lists/statuses")); | |
764 | 676 | } |
765 | 677 | |
766 | 678 | public HttpStatusCode CreateLists(string listname, Boolean isPrivate, string description, ref string content) |
@@ -776,7 +688,7 @@ namespace OpenTween | ||
776 | 688 | param.Add("description", description); |
777 | 689 | |
778 | 690 | return httpCon.GetContent(PostMethod, |
779 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/create.json" : "/1/lists/create.json"), | |
691 | + this.CreateTwitterUri("/1.1/lists/create.json"), | |
780 | 692 | param, |
781 | 693 | ref content, |
782 | 694 | null, |
@@ -790,11 +702,11 @@ namespace OpenTween | ||
790 | 702 | param.Add("list_id", list_id); |
791 | 703 | param.Add("cursor", cursor.ToString()); |
792 | 704 | return httpCon.GetContent(GetMethod, |
793 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/members.json" : "/1/lists/members.json"), | |
705 | + this.CreateTwitterUri("/1.1/lists/members.json"), | |
794 | 706 | param, |
795 | 707 | ref content, |
796 | 708 | this.CreateRetelimitHeadersDict(), |
797 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/members") : GetApiCallback); | |
709 | + this.CreateApiCalllback("/lists/members")); | |
798 | 710 | } |
799 | 711 | |
800 | 712 | public HttpStatusCode CreateListMembers(string list_id, string memberName, ref string content) |
@@ -803,85 +715,37 @@ namespace OpenTween | ||
803 | 715 | param.Add("list_id", list_id); |
804 | 716 | param.Add("screen_name", memberName); |
805 | 717 | return httpCon.GetContent(PostMethod, |
806 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/members/create.json" : "/1/lists/members/create.json"), | |
718 | + this.CreateTwitterUri("/1.1/lists/members/create.json"), | |
807 | 719 | param, |
808 | 720 | ref content, |
809 | 721 | null, |
810 | 722 | null); |
811 | 723 | } |
812 | 724 | |
813 | - //public HttpStatusCode CreateListMembers(string user, string list_id, string memberName, ref string content) | |
814 | - //{ | |
815 | - // //正常に動かないので旧APIで様子見 | |
816 | - // //Dictionary<string, string> param = new Dictionary<string, string>(); | |
817 | - // //param.Add("screen_name", user) | |
818 | - // //param.Add("list_id", list_id) | |
819 | - // //param.Add("member_screen_name", memberName) | |
820 | - // //return httpCon.GetContent(PostMethod, | |
821 | - // // CreateTwitterUri("/1/lists/members/create.json"), | |
822 | - // // param, | |
823 | - // // ref content, | |
824 | - // // null, | |
825 | - // // null) | |
826 | - // Dictionary<string, string> param = new Dictionary<string, string>(); | |
827 | - // param.Add("id", memberName) | |
828 | - // return httpCon.GetContent(PostMethod, | |
829 | - // CreateTwitterUri("/1/" + user + "/" + list_id + "/members.json"), | |
830 | - // param, | |
831 | - // ref content, | |
832 | - // null, | |
833 | - // null) | |
834 | - //} | |
835 | - | |
836 | 725 | public HttpStatusCode DeleteListMembers(string list_id, string memberName, ref string content) |
837 | 726 | { |
838 | 727 | Dictionary<string, string> param = new Dictionary<string, string>(); |
839 | 728 | param.Add("screen_name", memberName); |
840 | 729 | param.Add("list_id", list_id); |
841 | 730 | return httpCon.GetContent(PostMethod, |
842 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/members/destroy.json" : "/1/lists/members/destroy.json"), | |
731 | + this.CreateTwitterUri("/1.1/lists/members/destroy.json"), | |
843 | 732 | param, |
844 | 733 | ref content, |
845 | 734 | null, |
846 | 735 | null); |
847 | 736 | } |
848 | 737 | |
849 | - //public HttpStatusCode DeleteListMembers(string user, string list_id, string memberName, ref string content) | |
850 | - //{ | |
851 | - // //Dictionary<string, string> param = new Dictionary<string, string>(); | |
852 | - // //param.Add("screen_name", user) | |
853 | - // //param.Add("list_id", list_id) | |
854 | - // //param.Add("member_screen_name", memberName) | |
855 | - // //return httpCon.GetContent(PostMethod, | |
856 | - // // CreateTwitterUri("/1/lists/members/destroy.json"), | |
857 | - // // param, | |
858 | - // // ref content, | |
859 | - // // null, | |
860 | - // // null) | |
861 | - // Dictionary<string, string> param = new Dictionary<string, string>(); | |
862 | - // param.Add("id", memberName) | |
863 | - // param.Add("_method", "DELETE") | |
864 | - // return httpCon.GetContent(PostMethod, | |
865 | - // CreateTwitterUri("/1/" + user + "/" + list_id + "/members.json"), | |
866 | - // param, | |
867 | - // ref content, | |
868 | - // null, | |
869 | - // null) | |
870 | - //} | |
871 | - | |
872 | 738 | public HttpStatusCode ShowListMember(string list_id, string memberName, ref string content) |
873 | 739 | { |
874 | - //新APIがmember_screen_nameもmember_user_idも無視して、自分のIDを返してくる。 | |
875 | - //正式にドキュメントに反映されるまで旧APIを使用する | |
876 | 740 | Dictionary<string, string> param = new Dictionary<string, string>(); |
877 | 741 | param.Add("screen_name", memberName); |
878 | 742 | param.Add("list_id", list_id); |
879 | 743 | return httpCon.GetContent(GetMethod, |
880 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/members/show.json" : "/1/lists/members/show.json"), | |
744 | + this.CreateTwitterUri("/1.1/lists/members/show.json"), | |
881 | 745 | param, |
882 | 746 | ref content, |
883 | 747 | this.CreateRetelimitHeadersDict(), |
884 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/members/show") : GetApiCallback); | |
748 | + this.CreateApiCalllback("/lists/members/show")); | |
885 | 749 | } |
886 | 750 | #endregion |
887 | 751 |
@@ -893,15 +757,14 @@ namespace OpenTween | ||
893 | 757 | if (page != null) |
894 | 758 | param.Add("page", page.ToString()); |
895 | 759 | |
896 | - if (HttpTwitter.API11Enabled) | |
897 | - param.Add("id", statusid.ToString()); | |
760 | + param.Add("id", statusid.ToString()); | |
898 | 761 | |
899 | 762 | return httpCon.GetContent(GetMethod, |
900 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/retweeters/ids.json" : "/1/statuses/" + statusid + "/retweeted_by/ids.json"), | |
763 | + this.CreateTwitterUri("/1.1/statuses/retweeters/ids.json"), | |
901 | 764 | param, |
902 | 765 | ref content, |
903 | 766 | this.CreateRetelimitHeadersDict(), |
904 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/retweeters/ids") : GetApiCallback); | |
767 | + this.CreateApiCalllback("/statuses/retweeters/ids")); | |
905 | 768 | } |
906 | 769 | |
907 | 770 | public HttpStatusCode UpdateProfile(string name, string url, string location, string description, ref string content) |
@@ -915,7 +778,7 @@ namespace OpenTween | ||
915 | 778 | param.Add("include_entities", "true"); |
916 | 779 | |
917 | 780 | return httpCon.GetContent(PostMethod, |
918 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/account/update_profile.json" : "/1/account/update_profile.json"), | |
781 | + this.CreateTwitterUri("/1.1/account/update_profile.json"), | |
919 | 782 | param, |
920 | 783 | ref content, |
921 | 784 | null, |
@@ -928,7 +791,7 @@ namespace OpenTween | ||
928 | 791 | binary.Add(new KeyValuePair<string, FileInfo>("image", imageFile)); |
929 | 792 | |
930 | 793 | return httpCon.GetContent(PostMethod, |
931 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/account/update_profile_image.json" : "/1/account/update_profile_image.json"), | |
794 | + this.CreateTwitterUri("/1.1/account/update_profile_image.json"), | |
932 | 795 | null, |
933 | 796 | binary, |
934 | 797 | ref content, |
@@ -936,24 +799,6 @@ namespace OpenTween | ||
936 | 799 | null); |
937 | 800 | } |
938 | 801 | |
939 | - public HttpStatusCode GetRelatedResults(long id, ref string content) | |
940 | - { | |
941 | - //認証なくても取得できるが、protectedユーザー分が抜ける | |
942 | - Dictionary<string, string> param = new Dictionary<string, string>(); | |
943 | - | |
944 | - param.Add("id", id.ToString()); | |
945 | - param.Add("include_entities", "true"); | |
946 | - | |
947 | - // TODO: API v1.1 に存在しない API (旧 API で代替) | |
948 | - | |
949 | - return httpCon.GetContent(GetMethod, | |
950 | - CreateTwitterUri("/1/related_results/show.json"), | |
951 | - param, | |
952 | - ref content, | |
953 | - this.CreateRetelimitHeadersDict(), | |
954 | - GetApiCallback); | |
955 | - } | |
956 | - | |
957 | 802 | public HttpStatusCode GetBlockUserIds(ref string content, long? cursor) |
958 | 803 | { |
959 | 804 | var param = new Dictionary<string, string>(); |
@@ -962,36 +807,35 @@ namespace OpenTween | ||
962 | 807 | param.Add("cursor", cursor.ToString()); |
963 | 808 | |
964 | 809 | return httpCon.GetContent(GetMethod, |
965 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/blocks/ids.json" : "/1/blocks/blocking/ids.json"), | |
810 | + this.CreateTwitterUri("/1.1/blocks/ids.json"), | |
966 | 811 | param, |
967 | 812 | ref content, |
968 | 813 | this.CreateRetelimitHeadersDict(), |
969 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/blocks/ids") : GetApiCallback); | |
814 | + this.CreateApiCalllback("/blocks/ids")); | |
970 | 815 | } |
971 | 816 | |
972 | 817 | public HttpStatusCode GetConfiguration(ref string content) |
973 | 818 | { |
974 | 819 | return httpCon.GetContent(GetMethod, |
975 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/help/configuration.json" : "/1/help/configuration.json"), | |
820 | + this.CreateTwitterUri("/1.1/help/configuration.json"), | |
976 | 821 | null, |
977 | 822 | ref content, |
978 | 823 | this.CreateRetelimitHeadersDict(), |
979 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/help/configuration") : GetApiCallback); | |
824 | + this.CreateApiCalllback("/help/configuration")); | |
980 | 825 | } |
981 | 826 | |
982 | 827 | public HttpStatusCode VerifyCredentials(ref string content) |
983 | 828 | { |
984 | 829 | return httpCon.GetContent(GetMethod, |
985 | - CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/account/verify_credentials.json" : "/1/account/verify_credentials.json"), | |
830 | + this.CreateTwitterUri("/1.1/account/verify_credentials.json"), | |
986 | 831 | null, |
987 | 832 | ref content, |
988 | 833 | this.CreateRetelimitHeadersDict(), |
989 | - HttpTwitter.API11Enabled ? CreateApi11Calllback("/account/verify_credentials") : GetApiCallback); | |
834 | + this.CreateApiCalllback("/account/verify_credentials")); | |
990 | 835 | } |
991 | 836 | |
992 | 837 | #region Proxy API |
993 | 838 | private static string _twitterUrl = "api.twitter.com"; |
994 | - private static string _TwitterSearchUrl = "search.twitter.com"; | |
995 | 839 | private static string _twitterUserStreamUrl = "userstream.twitter.com"; |
996 | 840 | private static string _twitterStreamUrl = "stream.twitter.com"; |
997 | 841 |
@@ -1000,11 +844,6 @@ namespace OpenTween | ||
1000 | 844 | return new Uri(string.Format("{0}{1}{2}", _protocol, _twitterUrl, path)); |
1001 | 845 | } |
1002 | 846 | |
1003 | - private Uri CreateTwitterSearchUri(string path) | |
1004 | - { | |
1005 | - return new Uri(string.Format("{0}{1}{2}", _protocol, _TwitterSearchUrl, path)); | |
1006 | - } | |
1007 | - | |
1008 | 847 | private Uri CreateTwitterUserStreamUri(string path) |
1009 | 848 | { |
1010 | 849 | return new Uri(string.Format("{0}{1}{2}", "https://", _twitterUserStreamUrl, path)); |
@@ -1023,14 +862,6 @@ namespace OpenTween | ||
1023 | 862 | HttpOAuthApiProxy.ProxyHost = value; |
1024 | 863 | } |
1025 | 864 | } |
1026 | - | |
1027 | - public static string TwitterSearchUrl | |
1028 | - { | |
1029 | - set | |
1030 | - { | |
1031 | - _TwitterSearchUrl = value; | |
1032 | - } | |
1033 | - } | |
1034 | 865 | #endregion |
1035 | 866 | |
1036 | 867 | private Dictionary<string, string> CreateRetelimitHeadersDict() |
@@ -1050,18 +881,12 @@ namespace OpenTween | ||
1050 | 881 | }; |
1051 | 882 | } |
1052 | 883 | |
1053 | - private void GetApiCallback(Object sender, HttpStatusCode code, IDictionary<string, string> headerInfo, string content) | |
1054 | - { | |
1055 | - if (code < HttpStatusCode.InternalServerError) | |
1056 | - MyCommon.TwitterApiInfo.UpdateFromHeader(headerInfo); | |
1057 | - } | |
1058 | - | |
1059 | - private CallbackDelegate CreateApi11Calllback(string endpointName) | |
884 | + private CallbackDelegate CreateApiCalllback(string endpointName) | |
1060 | 885 | { |
1061 | 886 | return (sender, code, headerInfo, content) => |
1062 | 887 | { |
1063 | 888 | if (code < HttpStatusCode.InternalServerError) |
1064 | - MyCommon.TwitterApiInfo11.UpdateFromHeader(headerInfo, endpointName); | |
889 | + MyCommon.TwitterApiInfo.UpdateFromHeader(headerInfo, endpointName); | |
1065 | 890 | }; |
1066 | 891 | } |
1067 | 892 |
@@ -1079,7 +904,7 @@ namespace OpenTween | ||
1079 | 904 | param.Add("track", trackwords); |
1080 | 905 | |
1081 | 906 | return httpCon.GetContent(GetMethod, |
1082 | - CreateTwitterUserStreamUri(HttpTwitter.API11Enabled ? "/1.1/user.json" : "/2/user.json"), | |
907 | + this.CreateTwitterUserStreamUri("/1.1/user.json"), | |
1083 | 908 | param, |
1084 | 909 | ref content, |
1085 | 910 | userAgent); |
@@ -1096,7 +921,7 @@ namespace OpenTween | ||
1096 | 921 | param.Add("track", string.Join(",", trackwords.Split(" ".ToCharArray()))); |
1097 | 922 | |
1098 | 923 | return httpCon.GetContent(PostMethod, |
1099 | - CreateTwitterStreamUri(HttpTwitter.API11Enabled ? "/1.1/statuses/filter.json" : "/1/statuses/filter.json"), | |
924 | + this.CreateTwitterStreamUri("/1.1/statuses/filter.json"), | |
1100 | 925 | param, |
1101 | 926 | ref content, |
1102 | 927 | userAgent); |
@@ -506,22 +506,14 @@ namespace OpenTween | ||
506 | 506 | } |
507 | 507 | |
508 | 508 | [DataContract] |
509 | - public class SearchResultPhoenix | |
510 | - { | |
511 | - [DataMember(Name = "statuses")] public List<Status> Statuses; | |
512 | - [DataMember(Name = "next_page")] public string NextPage; | |
513 | - [DataMember(Name = "error")] public string ErrMsg; | |
514 | - } | |
515 | - | |
516 | - [DataContract] | |
517 | - public class SearchResult11 // API v1.1 | |
509 | + public class SearchResult | |
518 | 510 | { |
519 | 511 | [DataMember(Name = "statuses")] public List<Status> Statuses; |
520 | - [DataMember(Name = "search_metadata")] public SearchMetadata11 SearchMetadata; | |
512 | + [DataMember(Name = "search_metadata")] public SearchMetadata SearchMetadata; | |
521 | 513 | } |
522 | 514 | |
523 | 515 | [DataContract] |
524 | - public class SearchMetadata11 // API v1.1 | |
516 | + public class SearchMetadata | |
525 | 517 | { |
526 | 518 | [DataMember(Name = "max_id")] public long MaxId; |
527 | 519 | [DataMember(Name = "since_id")] public long SinceId; |
@@ -535,48 +527,6 @@ namespace OpenTween | ||
535 | 527 | } |
536 | 528 | |
537 | 529 | [DataContract] |
538 | - public class SearchResult | |
539 | - { | |
540 | - [DataMember(Name = "completed_in")] public double CompletedIn; | |
541 | - [DataMember(Name = "max_id")] public long MaxId; | |
542 | - [DataMember(Name = "next_page")] public string NextPageQuery; | |
543 | - [DataMember(Name = "page")] public int Page; | |
544 | - [DataMember(Name = "query")] public string Query; | |
545 | - [DataMember(Name = "refresh_url")] public string RefreshUrl; | |
546 | - [DataMember(Name = "results")] public List<SearchResultData> Results; | |
547 | - [DataMember(Name = "results_per_page")] public int ResultsPerPage; | |
548 | - [DataMember(Name = "since_id")] public long SinceId; | |
549 | - } | |
550 | - | |
551 | - [DataContract] | |
552 | - public class SearchResultData | |
553 | - { | |
554 | - [DataMember(Name = "created_at")] public string CreatedAt; | |
555 | - [DataMember(Name = "entities", IsRequired = false)] public Entities Entities; | |
556 | - [DataMember(Name = "from_user")] public string FromUser; | |
557 | - [DataMember(Name = "from_user_id")] public long FromUserId; | |
558 | - [DataMember(Name = "from_user_name")] public string FromUserName; | |
559 | - [DataMember(Name = "geo", IsRequired = false)] public Geo Geo; | |
560 | - [DataMember(Name = "id")] public long Id; | |
561 | - [DataMember(Name = "in_reply_to_status_id", IsRequired = false)] public long InReplyToStatusId = 0; | |
562 | - [DataMember(Name = "iso_language_code")] public string IsoLanguageCode; | |
563 | - [DataMember(Name = "meta_data")] public SearchMetaData MetaData; | |
564 | - [DataMember(Name = "profile_image_url")] public string ProfileImageUrl; | |
565 | - [DataMember(Name = "source")] public string Source; | |
566 | - [DataMember(Name = "text")] public string Text; | |
567 | - [DataMember(Name = "to_user")] public string ToUser; | |
568 | - [DataMember(Name = "to_user_id")] public long? ToUserId; | |
569 | - [DataMember(Name = "to_user_name")] public string ToUserName; | |
570 | - } | |
571 | - | |
572 | - [DataContract] | |
573 | - public class SearchMetaData | |
574 | - { | |
575 | - [DataMember(Name = "recent_retweets")] public int RecentRetweets; | |
576 | - [DataMember(Name = "result_type")] public string ResultType; | |
577 | - } | |
578 | - | |
579 | - [DataContract] | |
580 | 530 | public class PhotoSize |
581 | 531 | { |
582 | 532 | [DataMember(Name = "h")] public int Height; |
@@ -711,7 +711,6 @@ namespace OpenTween | ||
711 | 711 | } |
712 | 712 | |
713 | 713 | public static TwitterApiStatus TwitterApiInfo = new TwitterApiStatus(); |
714 | - public static TwitterApiStatus11 TwitterApiInfo11 = new TwitterApiStatus11(); | |
715 | 714 | |
716 | 715 | public static bool IsAnimatedGif(string filename) |
717 | 716 | { |
@@ -56,7 +56,6 @@ | ||
56 | 56 | <Compile Include="Api\ApiLimit.cs" /> |
57 | 57 | <Compile Include="Api\TwitterApiAccessLevel.cs" /> |
58 | 58 | <Compile Include="Api\TwitterApiStatus.cs" /> |
59 | - <Compile Include="Api\TwitterApiStatus11.cs" /> | |
60 | 59 | <Compile Include="ApplicationEvents.cs"> |
61 | 60 | <SubType>Code</SubType> |
62 | 61 | </Compile> |
@@ -2,6 +2,7 @@ | ||
2 | 2 | |
3 | 3 | ==== Ver 1.1.3-beta1(2013/xx/xx) |
4 | 4 | * CHG: Twitter API のエラー処理を改善 |
5 | + * CHG: 旧 API v1 関連の機能を削除 | |
5 | 6 | * FIX: 「片思いユーザーリストを取得する」を無効にするとRT非表示設定が反映されない問題の修正 (thx @ui_nyan!) |
6 | 7 | * FIX: ブロックされているユーザーのツイートをふぁぼった時にUserStreamsが切断されてしまう問題の修正 |
7 | 8 | * FIX: 片思いユーザーリストの更新に失敗すると希に片思い表示がされなくなる現象を修正 |
@@ -192,7 +192,6 @@ namespace OpenTween | ||
192 | 192 | public bool UseAtIdSupplement = true; |
193 | 193 | public bool UseHashSupplement = true; |
194 | 194 | public string TwitterUrl = "api.twitter.com"; |
195 | - public string TwitterSearchUrl = "search.twitter.com"; | |
196 | 195 | public bool HotkeyEnabled = false; |
197 | 196 | public Keys HotkeyModifier = Keys.None; |
198 | 197 | public Keys HotkeyKey = Keys.None; |
@@ -35,32 +35,17 @@ namespace OpenTween | ||
35 | 35 | /// API 実行回数制限に到達するまでの目安を表示する ToolStripItem |
36 | 36 | /// </summary> |
37 | 37 | [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.All)] |
38 | - public class ToolStripAPIGauge : ToolStripButton | |
38 | + public class ToolStripAPIGauge : ToolStripLabel | |
39 | 39 | { |
40 | 40 | public ToolStripAPIGauge() |
41 | 41 | : base() |
42 | 42 | { |
43 | - this.Text = "API v1.1 ???/???"; | |
43 | + this.Text = "API ???/???"; | |
44 | 44 | this.ToolTipText = "API rest ???/???" + Environment.NewLine + "(reset after ??? minutes)"; |
45 | 45 | |
46 | 46 | this.DisplayStyle = ToolStripItemDisplayStyle.Text; |
47 | 47 | } |
48 | 48 | |
49 | - [DefaultValue(true)] | |
50 | - [RefreshProperties(RefreshProperties.Repaint)] | |
51 | - public bool API11Enabled | |
52 | - { | |
53 | - get { return this._API11Enabled; } | |
54 | - set | |
55 | - { | |
56 | - this._API11Enabled = value; | |
57 | - | |
58 | - this.UpdateText(); | |
59 | - this.Invalidate(); | |
60 | - } | |
61 | - } | |
62 | - private bool _API11Enabled = true; | |
63 | - | |
64 | 49 | /// <summary> |
65 | 50 | /// ゲージに表示される横棒グラフの幅 |
66 | 51 | /// </summary> |
@@ -182,16 +167,10 @@ namespace OpenTween | ||
182 | 167 | |
183 | 168 | protected virtual void UpdateText() |
184 | 169 | { |
185 | - string apiVersionText; | |
186 | 170 | string remainCountText; |
187 | 171 | string maxCountText; |
188 | 172 | string minuteText; |
189 | 173 | |
190 | - if (this._API11Enabled) | |
191 | - apiVersionText = "v1.1"; | |
192 | - else | |
193 | - apiVersionText = "v1"; | |
194 | - | |
195 | 174 | if (this._ApiLimit == null) |
196 | 175 | { |
197 | 176 | remainCountText = "???"; |
@@ -205,8 +184,8 @@ namespace OpenTween | ||
205 | 184 | minuteText = Math.Ceiling(this.remainMinutes).ToString(); |
206 | 185 | } |
207 | 186 | |
208 | - var textFormat = "API {0} {1}/{2}"; | |
209 | - this.Text = string.Format(textFormat, apiVersionText, remainCountText, maxCountText); | |
187 | + var textFormat = "API {0}/{1}"; | |
188 | + this.Text = string.Format(textFormat, remainCountText, maxCountText); | |
210 | 189 | |
211 | 190 | var toolTipTextFormat = |
212 | 191 | "API rest {0}/{1}" + Environment.NewLine + |
@@ -556,7 +556,6 @@ namespace OpenTween | ||
556 | 556 | SecurityManager = new InternetSecurityManager(PostBrowser); |
557 | 557 | |
558 | 558 | MyCommon.TwitterApiInfo.AccessLimitUpdated += TwitterApiStatus_AccessLimitUpdated; |
559 | - MyCommon.TwitterApiInfo11.AccessLimitUpdated += TwitterApiStatus_AccessLimitUpdated; | |
560 | 559 | Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; |
561 | 560 | |
562 | 561 | string[] cmdArgs = Environment.GetCommandLineArgs(); |
@@ -648,9 +647,7 @@ namespace OpenTween | ||
648 | 647 | |
649 | 648 | //設定画面への反映 |
650 | 649 | HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl; |
651 | - HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl; | |
652 | 650 | SettingDialog.TwitterApiUrl = _cfgCommon.TwitterUrl; |
653 | - SettingDialog.TwitterSearchApiUrl = _cfgCommon.TwitterSearchUrl; | |
654 | 651 | |
655 | 652 | //認証関連 |
656 | 653 | if (string.IsNullOrEmpty(_cfgCommon.Token)) _cfgCommon.UserName = ""; |
@@ -998,7 +995,6 @@ namespace OpenTween | ||
998 | 995 | ShortUrl.BitlyId = SettingDialog.BitlyUser; |
999 | 996 | ShortUrl.BitlyKey = SettingDialog.BitlyPwd; |
1000 | 997 | HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl; |
1001 | - HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl; | |
1002 | 998 | tw.TrackWord = _cfgCommon.TrackWord; |
1003 | 999 | TrackToolStripMenuItem.Checked = !String.IsNullOrEmpty(tw.TrackWord); |
1004 | 1000 | tw.AllAtReply = _cfgCommon.AllAtReply; |
@@ -3947,7 +3943,6 @@ namespace OpenTween | ||
3947 | 3943 | ShortUrl.BitlyId = SettingDialog.BitlyUser; |
3948 | 3944 | ShortUrl.BitlyKey = SettingDialog.BitlyPwd; |
3949 | 3945 | HttpTwitter.TwitterUrl = _cfgCommon.TwitterUrl; |
3950 | - HttpTwitter.TwitterSearchUrl = _cfgCommon.TwitterSearchUrl; | |
3951 | 3946 | |
3952 | 3947 | HttpConnection.InitializeConnection(SettingDialog.DefaultTimeOut, |
3953 | 3948 | SettingDialog.SelectedProxyType, |
@@ -7886,7 +7881,6 @@ namespace OpenTween | ||
7886 | 7881 | _cfgCommon.HashIsPermanent = HashMgr.IsPermanent; |
7887 | 7882 | _cfgCommon.HashIsNotAddToAtReply = HashMgr.IsNotAddToAtReply; |
7888 | 7883 | _cfgCommon.TwitterUrl = SettingDialog.TwitterApiUrl; |
7889 | - _cfgCommon.TwitterSearchUrl = SettingDialog.TwitterSearchApiUrl; | |
7890 | 7884 | _cfgCommon.HotkeyEnabled = SettingDialog.HotkeyEnabled; |
7891 | 7885 | _cfgCommon.HotkeyModifier = SettingDialog.HotkeyMod; |
7892 | 7886 | _cfgCommon.HotkeyKey = SettingDialog.HotkeyKey; |
@@ -9508,17 +9502,10 @@ namespace OpenTween | ||
9508 | 9502 | } |
9509 | 9503 | else |
9510 | 9504 | { |
9511 | - if (sender is TwitterApiStatus11 && this._apiGauge.API11Enabled) | |
9505 | + var endpointName = (e as TwitterApiStatus.AccessLimitUpdatedEventArgs).EndpointName; | |
9506 | + if (endpointName == "/statuses/home_timeline" || endpointName == null) | |
9512 | 9507 | { |
9513 | - var endpointName = (e as TwitterApiStatus11.AccessLimitUpdatedEventArgs).EndpointName; | |
9514 | - if (endpointName == "/statuses/home_timeline" || endpointName == null) | |
9515 | - { | |
9516 | - this._apiGauge.ApiLimit = MyCommon.TwitterApiInfo11.AccessLimit["/statuses/home_timeline"]; | |
9517 | - } | |
9518 | - } | |
9519 | - else if (sender is TwitterApiStatus && !this._apiGauge.API11Enabled) | |
9520 | - { | |
9521 | - this._apiGauge.ApiLimit = MyCommon.TwitterApiInfo.AccessLimit; | |
9508 | + this._apiGauge.ApiLimit = MyCommon.TwitterApiInfo.AccessLimit["/statuses/home_timeline"]; | |
9522 | 9509 | } |
9523 | 9510 | } |
9524 | 9511 | } |
@@ -11074,10 +11061,7 @@ namespace OpenTween | ||
11074 | 11061 | |
11075 | 11062 | private void GetApiInfo_Dowork(object sender, DoWorkEventArgs e) |
11076 | 11063 | { |
11077 | - if (HttpTwitter.API11Enabled) | |
11078 | - e.Result = tw.GetInfoApi11(); | |
11079 | - else | |
11080 | - e.Result = tw.GetInfoApi10(); | |
11064 | + e.Result = tw.GetInfoApi(); | |
11081 | 11065 | } |
11082 | 11066 | |
11083 | 11067 | private void ApiUsageInfoMenuItem_Click(object sender, EventArgs e) |
@@ -11088,28 +11072,14 @@ namespace OpenTween | ||
11088 | 11072 | { |
11089 | 11073 | dlg.ShowDialog(); |
11090 | 11074 | |
11091 | - TwitterApiAccessLevel? accessLevel = null; | |
11092 | - ApiLimit timelineLimit = null, mediaLimit = null; | |
11093 | - | |
11094 | - if (dlg.Result is TwitterApiStatus) | |
11095 | - { | |
11096 | - var result = (TwitterApiStatus)dlg.Result; | |
11075 | + var result = (TwitterApiStatus)dlg.Result; | |
11097 | 11076 | |
11098 | - accessLevel = result.AccessLevel; | |
11099 | - timelineLimit = result.AccessLimit; | |
11100 | - mediaLimit = result.MediaUploadLimit; | |
11101 | - } | |
11102 | - else if (dlg.Result is TwitterApiStatus11) | |
11077 | + if (result == null) | |
11103 | 11078 | { |
11104 | - var result = (TwitterApiStatus11)dlg.Result; | |
11079 | + var accessLevel = result.AccessLevel; | |
11080 | + var timelineLimit = result.AccessLimit["/statuses/home_timeline"]; | |
11081 | + var mediaLimit = result.MediaUploadLimit; | |
11105 | 11082 | |
11106 | - accessLevel = result.AccessLevel; | |
11107 | - timelineLimit = result.AccessLimit["/statuses/home_timeline"]; | |
11108 | - mediaLimit = result.MediaUploadLimit; | |
11109 | - } | |
11110 | - | |
11111 | - if (accessLevel != null) | |
11112 | - { | |
11113 | 11083 | tmp.AppendLine(Properties.Resources.ApiInfo1 + timelineLimit.AccessLimitCount); |
11114 | 11084 | tmp.AppendLine(Properties.Resources.ApiInfo2 + timelineLimit.AccessLimitRemain); |
11115 | 11085 | tmp.AppendLine(Properties.Resources.ApiInfo3 + timelineLimit.AccessLimitResetDate); |
@@ -12244,18 +12214,6 @@ namespace OpenTween | ||
12244 | 12214 | this.gh.NotifyClicked += GrowlHelper_Callback; |
12245 | 12215 | |
12246 | 12216 | this._apiGauge = new ToolStripAPIGauge(); |
12247 | - this._apiGauge.Click += (s, e) => | |
12248 | - { | |
12249 | - var api11Enabled = !HttpTwitter.API11Enabled; | |
12250 | - | |
12251 | - HttpTwitter.API11Enabled = api11Enabled; | |
12252 | - (s as ToolStripAPIGauge).API11Enabled = api11Enabled; | |
12253 | - | |
12254 | - if (api11Enabled) | |
12255 | - MyCommon.TwitterApiInfo11.Reset(); | |
12256 | - else | |
12257 | - MyCommon.TwitterApiInfo.Reset(); | |
12258 | - }; | |
12259 | 12217 | this.StatusStrip1.Items.Insert(2, this._apiGauge); |
12260 | 12218 | |
12261 | 12219 | this.ReplaceAppName(); |
@@ -176,19 +176,13 @@ namespace OpenTween | ||
176 | 176 | { |
177 | 177 | get |
178 | 178 | { |
179 | - if (HttpTwitter.API11Enabled) | |
180 | - return MyCommon.TwitterApiInfo11.AccessLevel; | |
181 | - else | |
182 | - return MyCommon.TwitterApiInfo.AccessLevel; | |
179 | + return MyCommon.TwitterApiInfo.AccessLevel; | |
183 | 180 | } |
184 | 181 | } |
185 | 182 | |
186 | 183 | protected void ResetApiStatus() |
187 | 184 | { |
188 | - if (HttpTwitter.API11Enabled) | |
189 | - MyCommon.TwitterApiInfo11.Reset(); | |
190 | - else | |
191 | - MyCommon.TwitterApiInfo.Reset(); | |
185 | + MyCommon.TwitterApiInfo.Reset(); | |
192 | 186 | } |
193 | 187 | |
194 | 188 | public string Authenticate(string username, string password) |
@@ -1747,13 +1741,12 @@ namespace OpenTween | ||
1747 | 1741 | return ""; |
1748 | 1742 | } |
1749 | 1743 | |
1750 | - // API v1.1 | |
1751 | - private string CreatePostsFromSearch11Json(string content, TabClass tab, bool read, int count, ref long minimumId, bool more) | |
1744 | + private string CreatePostsFromSearchJson(string content, TabClass tab, bool read, int count, ref long minimumId, bool more) | |
1752 | 1745 | { |
1753 | - TwitterDataModel.SearchResult11 items; | |
1746 | + TwitterDataModel.SearchResult items; | |
1754 | 1747 | try |
1755 | 1748 | { |
1756 | - items = MyCommon.CreateDataFromJson<TwitterDataModel.SearchResult11>(content); | |
1749 | + items = MyCommon.CreateDataFromJson<TwitterDataModel.SearchResult>(content); | |
1757 | 1750 | } |
1758 | 1751 | catch (SerializationException ex) |
1759 | 1752 | { |
@@ -1803,152 +1796,6 @@ namespace OpenTween | ||
1803 | 1796 | return ""; |
1804 | 1797 | } |
1805 | 1798 | |
1806 | - private string CreatePostsFromSearchJson(string content, TabClass tab, bool read, int count, ref long minimumId, bool more) | |
1807 | - { | |
1808 | - TwitterDataModel.SearchResult items; | |
1809 | - try | |
1810 | - { | |
1811 | - items = MyCommon.CreateDataFromJson<TwitterDataModel.SearchResult>(content); | |
1812 | - } | |
1813 | - catch (SerializationException ex) | |
1814 | - { | |
1815 | - MyCommon.TraceOut(ex.Message + Environment.NewLine + content); | |
1816 | - return "Json Parse Error(DataContractJsonSerializer)"; | |
1817 | - } | |
1818 | - catch (Exception ex) | |
1819 | - { | |
1820 | - MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); | |
1821 | - return "Invalid Json!"; | |
1822 | - } | |
1823 | - foreach (var result in items.Results) | |
1824 | - { | |
1825 | - PostClass post = null; | |
1826 | - post = CreatePostsFromSearchResultData(result); | |
1827 | - if (post == null) continue; | |
1828 | - | |
1829 | - if (minimumId > post.StatusId) minimumId = post.StatusId; | |
1830 | - if (!more && post.StatusId > tab.SinceId) tab.SinceId = post.StatusId; | |
1831 | - //二重取得回避 | |
1832 | - lock (LockObj) | |
1833 | - { | |
1834 | - if (tab == null) | |
1835 | - { | |
1836 | - if (TabInformations.GetInstance().ContainsKey(post.StatusId)) continue; | |
1837 | - } | |
1838 | - else | |
1839 | - { | |
1840 | - if (TabInformations.GetInstance().ContainsKey(post.StatusId, tab.TabName)) continue; | |
1841 | - } | |
1842 | - } | |
1843 | - | |
1844 | - post.IsRead = read; | |
1845 | - if ((post.IsMe && !read) && this._readOwnPost) post.IsRead = true; | |
1846 | - | |
1847 | - if (tab != null) post.RelTabName = tab.TabName; | |
1848 | - //非同期アイコン取得&StatusDictionaryに追加 | |
1849 | - TabInformations.GetInstance().AddPost(post); | |
1850 | - } | |
1851 | - | |
1852 | - return ""; | |
1853 | - } | |
1854 | - | |
1855 | - private PostClass CreatePostsFromSearchResultData(TwitterDataModel.SearchResultData status) | |
1856 | - { | |
1857 | - var post = new PostClass(); | |
1858 | - post.StatusId = status.Id; | |
1859 | - post.CreatedAt = MyCommon.DateTimeParse(status.CreatedAt); | |
1860 | - //本文 | |
1861 | - post.TextFromApi = status.Text; | |
1862 | - var entities = status.Entities; | |
1863 | - post.Source = WebUtility.HtmlDecode(status.Source); | |
1864 | - post.InReplyToStatusId = status.InReplyToStatusId; | |
1865 | - post.InReplyToUser = status.ToUser; | |
1866 | - post.InReplyToUserId = status.ToUserId; | |
1867 | - | |
1868 | - if (status.Geo != null) post.PostGeo = new PostClass.StatusGeo { Lat = status.Geo.Coordinates[0], Lng = status.Geo.Coordinates[1] }; | |
1869 | - | |
1870 | - if (status.FromUser == null) return null; | |
1871 | - | |
1872 | - post.UserId = status.FromUserId; | |
1873 | - post.ScreenName = status.FromUser; | |
1874 | - post.Nickname = status.FromUserName.Trim(); | |
1875 | - post.ImageUrl = status.ProfileImageUrl; | |
1876 | - post.IsProtect = false; | |
1877 | - post.IsMe = post.ScreenName.ToLower().Equals(this._uname); | |
1878 | - | |
1879 | - //幻覚fav対策 | |
1880 | - var tc = TabInformations.GetInstance().GetTabByType(MyCommon.TabUsageType.Favorites); | |
1881 | - post.IsFav = tc.Contains(post.StatusId) && TabInformations.GetInstance()[post.StatusId].IsFav; | |
1882 | - | |
1883 | - //HTMLに整形 | |
1884 | - string textFromApi = post.TextFromApi; | |
1885 | - post.Text = this.CreateHtmlAnchor(ref textFromApi, post.ReplyToList, entities, post.Media); | |
1886 | - post.TextFromApi = this.ReplaceTextFromApi(post.TextFromApi, entities); | |
1887 | - post.TextFromApi = WebUtility.HtmlDecode(post.TextFromApi); | |
1888 | - post.TextFromApi = post.TextFromApi.Replace("<3", "\u2661"); | |
1889 | - | |
1890 | - //Source整形 | |
1891 | - this.CreateSource(post); | |
1892 | - | |
1893 | - post.IsReply = post.ReplyToList.Contains(this._uname); | |
1894 | - post.IsExcludeReply = false; | |
1895 | - post.IsOwl = false; | |
1896 | - post.IsDm = false; | |
1897 | - | |
1898 | - return post; | |
1899 | - } | |
1900 | - | |
1901 | - private string CreatePostsFromPhoenixSearch(string content, MyCommon.WORKERTYPE gType, TabClass tab, bool read, int count, ref long minimumId, ref string nextPageQuery) | |
1902 | - { | |
1903 | - TwitterDataModel.SearchResultPhoenix items; | |
1904 | - try | |
1905 | - { | |
1906 | - items = MyCommon.CreateDataFromJson<TwitterDataModel.SearchResultPhoenix>(content); | |
1907 | - } | |
1908 | - catch(SerializationException ex) | |
1909 | - { | |
1910 | - MyCommon.TraceOut(ex.Message + Environment.NewLine + content); | |
1911 | - return "Json Parse Error(DataContractJsonSerializer)"; | |
1912 | - } | |
1913 | - catch(Exception ex) | |
1914 | - { | |
1915 | - MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); | |
1916 | - return "Invalid Json!"; | |
1917 | - } | |
1918 | - | |
1919 | - nextPageQuery = items.NextPage; | |
1920 | - | |
1921 | - foreach (var status in items.Statuses) | |
1922 | - { | |
1923 | - PostClass post = null; | |
1924 | - post = CreatePostsFromStatusData(status); | |
1925 | - if (post == null) continue; | |
1926 | - | |
1927 | - if (minimumId > post.StatusId) minimumId = post.StatusId; | |
1928 | - //二重取得回避 | |
1929 | - lock (LockObj) | |
1930 | - { | |
1931 | - if (tab == null) | |
1932 | - { | |
1933 | - if (TabInformations.GetInstance().ContainsKey(post.StatusId)) continue; | |
1934 | - } | |
1935 | - else | |
1936 | - { | |
1937 | - if (TabInformations.GetInstance().ContainsKey(post.StatusId, tab.TabName)) continue; | |
1938 | - } | |
1939 | - } | |
1940 | - | |
1941 | - post.IsRead = read; | |
1942 | - if (post.IsMe && !read && _readOwnPost) post.IsRead = true; | |
1943 | - | |
1944 | - if (tab != null) post.RelTabName = tab.TabName; | |
1945 | - //非同期アイコン取得&StatusDictionaryに追加 | |
1946 | - TabInformations.GetInstance().AddPost(post); | |
1947 | - } | |
1948 | - | |
1949 | - return string.IsNullOrEmpty(items.ErrMsg) ? "" : "Err:" + items.ErrMsg; | |
1950 | - } | |
1951 | - | |
1952 | 1799 | public string GetListStatus(bool read, |
1953 | 1800 | TabClass tab, |
1954 | 1801 | bool more, |
@@ -2045,25 +1892,9 @@ namespace OpenTween | ||
2045 | 1892 | } |
2046 | 1893 | relPosts.Add(tab.RelationTargetPost.StatusId, tab.RelationTargetPost.Clone()); |
2047 | 1894 | |
2048 | - PostClass nextPost; | |
2049 | - int loopCount; | |
2050 | - | |
2051 | - // 一周目: 非公式な related_results API を使用してリプライチェインを辿る | |
2052 | - if (!HttpTwitter.API11Enabled) | |
2053 | - { | |
2054 | - nextPost = relPosts[tab.RelationTargetPost.StatusId]; | |
2055 | - loopCount = 1; | |
2056 | - do | |
2057 | - { | |
2058 | - rslt = this.GetRelatedResultsApi(nextPost, relPosts); | |
2059 | - if (!string.IsNullOrEmpty(rslt)) break; | |
2060 | - nextPost = FindTopOfReplyChain(relPosts, nextPost.StatusId); | |
2061 | - } while (nextPost.InReplyToStatusId != null && loopCount++ <= 5); | |
2062 | - } | |
2063 | - | |
2064 | - // 二周目: in_reply_to_status_id を使用してリプライチェインを辿る | |
2065 | - nextPost = FindTopOfReplyChain(relPosts, tab.RelationTargetPost.StatusId); | |
2066 | - loopCount = 1; | |
1895 | + // in_reply_to_status_id を使用してリプライチェインを辿る | |
1896 | + var nextPost = FindTopOfReplyChain(relPosts, tab.RelationTargetPost.StatusId); | |
1897 | + var loopCount = 1; | |
2067 | 1898 | while (nextPost.InReplyToStatusId != null && loopCount++ <= 20) |
2068 | 1899 | { |
2069 | 1900 | var inReplyToId = nextPost.InReplyToStatusId.Value; |
@@ -2130,65 +1961,6 @@ namespace OpenTween | ||
2130 | 1961 | return rslt; |
2131 | 1962 | } |
2132 | 1963 | |
2133 | - private string GetRelatedResultsApi(PostClass post, | |
2134 | - IDictionary<Int64, PostClass> relatedPosts) | |
2135 | - { | |
2136 | - if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return ""; | |
2137 | - | |
2138 | - if (MyCommon._endingFlag) return ""; | |
2139 | - | |
2140 | - HttpStatusCode res; | |
2141 | - var content = ""; | |
2142 | - try | |
2143 | - { | |
2144 | - if (post.RetweetedId != null) | |
2145 | - { | |
2146 | - res = twCon.GetRelatedResults(post.RetweetedId.Value, ref content); | |
2147 | - } | |
2148 | - else | |
2149 | - { | |
2150 | - res = twCon.GetRelatedResults(post.StatusId, ref content); | |
2151 | - } | |
2152 | - } | |
2153 | - catch(Exception ex) | |
2154 | - { | |
2155 | - return "Err:" + ex.Message; | |
2156 | - } | |
2157 | - | |
2158 | - var err = this.CheckStatusCode(res, content); | |
2159 | - if (err != null) return err; | |
2160 | - | |
2161 | - List<TwitterDataModel.RelatedResult> items; | |
2162 | - try | |
2163 | - { | |
2164 | - items = MyCommon.CreateDataFromJson<List<TwitterDataModel.RelatedResult>>(content); | |
2165 | - } | |
2166 | - catch(SerializationException ex) | |
2167 | - { | |
2168 | - MyCommon.TraceOut(ex.Message + Environment.NewLine + content); | |
2169 | - return "Json Parse Error(DataContractJsonSerializer)"; | |
2170 | - } | |
2171 | - catch(Exception ex) | |
2172 | - { | |
2173 | - MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); | |
2174 | - return "Invalid Json!"; | |
2175 | - } | |
2176 | - | |
2177 | - foreach (var relatedData in items) | |
2178 | - { | |
2179 | - foreach (var result in relatedData.Results) | |
2180 | - { | |
2181 | - var item = CreatePostsFromStatusData(result.Status); | |
2182 | - if (item == null) continue; | |
2183 | - //非同期アイコン取得&StatusDictionaryに追加 | |
2184 | - if (!relatedPosts.ContainsKey(item.StatusId)) | |
2185 | - relatedPosts.Add(item.StatusId, item); | |
2186 | - } | |
2187 | - } | |
2188 | - | |
2189 | - return ""; | |
2190 | - } | |
2191 | - | |
2192 | 1964 | public string GetSearch(bool read, |
2193 | 1965 | TabClass tab, |
2194 | 1966 | bool more) |
@@ -2243,80 +2015,7 @@ namespace OpenTween | ||
2243 | 2015 | |
2244 | 2016 | if (!TabInformations.GetInstance().ContainsTab(tab)) return ""; |
2245 | 2017 | |
2246 | - if (HttpTwitter.API11Enabled) | |
2247 | - return this.CreatePostsFromSearch11Json(content, tab, read, count, ref tab.OldestId, more); | |
2248 | - else | |
2249 | - return this.CreatePostsFromSearchJson(content, tab, read, count, ref tab.OldestId, more); | |
2250 | - } | |
2251 | - | |
2252 | - public string GetPhoenixSearch(bool read, | |
2253 | - TabClass tab, | |
2254 | - bool more) | |
2255 | - { | |
2256 | - if (MyCommon._endingFlag) return ""; | |
2257 | - | |
2258 | - HttpStatusCode res; | |
2259 | - var content = ""; | |
2260 | - int? page = null; | |
2261 | - long? sinceId = null; | |
2262 | - var count = 100; | |
2263 | - var querystr = ""; | |
2264 | - if (AppendSettingDialog.Instance.UseAdditionalCount && | |
2265 | - AppendSettingDialog.Instance.SearchCountApi != 0) | |
2266 | - { | |
2267 | - count = AppendSettingDialog.Instance.SearchCountApi; | |
2268 | - } | |
2269 | - if (more) | |
2270 | - { | |
2271 | - page = tab.GetSearchPage(count); | |
2272 | - if (!string.IsNullOrEmpty(tab.NextPageQuery)) | |
2273 | - { | |
2274 | - querystr = tab.NextPageQuery; | |
2275 | - } | |
2276 | - } | |
2277 | - else | |
2278 | - { | |
2279 | - sinceId = tab.SinceId; | |
2280 | - } | |
2281 | - | |
2282 | - try | |
2283 | - { | |
2284 | - if (string.IsNullOrEmpty(querystr)) | |
2285 | - { | |
2286 | - res = twCon.PhoenixSearch(tab.SearchWords, tab.SearchLang, count, page, sinceId, ref content); | |
2287 | - } | |
2288 | - else | |
2289 | - { | |
2290 | - res = twCon.PhoenixSearch(querystr, ref content); | |
2291 | - } | |
2292 | - } | |
2293 | - catch(Exception ex) | |
2294 | - { | |
2295 | - return "Err:" + ex.Message; | |
2296 | - } | |
2297 | - switch (res) | |
2298 | - { | |
2299 | - case HttpStatusCode.BadRequest: | |
2300 | - return "Invalid query"; | |
2301 | - case HttpStatusCode.NotFound: | |
2302 | - return "Invalid query"; | |
2303 | - case HttpStatusCode.PaymentRequired: //API Documentには420と書いてあるが、該当コードがないので402にしてある | |
2304 | - return "Search API Limit?"; | |
2305 | - case HttpStatusCode.OK: | |
2306 | - break; | |
2307 | - default: | |
2308 | - return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")"; | |
2309 | - } | |
2310 | - | |
2311 | - if (!TabInformations.GetInstance().ContainsTab(tab)) return ""; | |
2312 | - | |
2313 | - //// TODO | |
2314 | - //// 遡るための情報max_idやnext_pageの情報を保持する | |
2315 | - | |
2316 | - string nextPageQuery = tab.NextPageQuery; | |
2317 | - var ret = CreatePostsFromPhoenixSearch(content, MyCommon.WORKERTYPE.PublicSearch, tab, read, count, ref tab.OldestId, ref nextPageQuery); | |
2318 | - tab.NextPageQuery = nextPageQuery; | |
2319 | - return ret; | |
2018 | + return this.CreatePostsFromSearchJson(content, tab, read, count, ref tab.OldestId, more); | |
2320 | 2019 | } |
2321 | 2020 | |
2322 | 2021 | private string CreateDirectMessagesFromJson(string content, MyCommon.WORKERTYPE gType, bool read) |
@@ -2847,89 +2546,6 @@ namespace OpenTween | ||
2847 | 2546 | |
2848 | 2547 | public string GetListsApi() |
2849 | 2548 | { |
2850 | - return HttpTwitter.API11Enabled ? this.GetListsApi11() : this.GetListsApi10(); | |
2851 | - } | |
2852 | - | |
2853 | - private string GetListsApi10() | |
2854 | - { | |
2855 | - if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return ""; | |
2856 | - | |
2857 | - HttpStatusCode res; | |
2858 | - var content = ""; | |
2859 | - long cursor = -1; | |
2860 | - | |
2861 | - var lists = new List<ListElement>(); | |
2862 | - do | |
2863 | - { | |
2864 | - try | |
2865 | - { | |
2866 | - res = twCon.GetLists(this.Username, cursor, ref content); | |
2867 | - } | |
2868 | - catch(Exception ex) | |
2869 | - { | |
2870 | - return "Err:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")"; | |
2871 | - } | |
2872 | - | |
2873 | - var err = this.CheckStatusCode(res, content); | |
2874 | - if (err != null) return err; | |
2875 | - | |
2876 | - try | |
2877 | - { | |
2878 | - var lst = MyCommon.CreateDataFromJson<TwitterDataModel.Lists>(content); | |
2879 | - lists.AddRange(from le in lst.lists select new ListElement(le, this)); | |
2880 | - cursor = lst.NextCursor; | |
2881 | - } | |
2882 | - catch(SerializationException ex) | |
2883 | - { | |
2884 | - MyCommon.TraceOut(ex.Message + Environment.NewLine + content); | |
2885 | - return "Err:Json Parse Error(DataContractJsonSerializer)"; | |
2886 | - } | |
2887 | - catch(Exception ex) | |
2888 | - { | |
2889 | - MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); | |
2890 | - return "Err:Invalid Json!"; | |
2891 | - } | |
2892 | - } while (cursor != 0); | |
2893 | - | |
2894 | - cursor = -1; | |
2895 | - do | |
2896 | - { | |
2897 | - try | |
2898 | - { | |
2899 | - res = twCon.GetListsSubscriptions(this.Username, cursor, ref content); | |
2900 | - } | |
2901 | - catch(Exception ex) | |
2902 | - { | |
2903 | - return "Err:" + ex.Message + "(" + MethodBase.GetCurrentMethod().Name + ")"; | |
2904 | - } | |
2905 | - | |
2906 | - var err = this.CheckStatusCode(res, content); | |
2907 | - if (err != null) return err; | |
2908 | - | |
2909 | - try | |
2910 | - { | |
2911 | - var lst = MyCommon.CreateDataFromJson<TwitterDataModel.Lists>(content); | |
2912 | - lists.AddRange(from le in lst.lists select new ListElement(le, this)); | |
2913 | - cursor = lst.NextCursor; | |
2914 | - } | |
2915 | - catch(SerializationException ex) | |
2916 | - { | |
2917 | - MyCommon.TraceOut(ex.Message + Environment.NewLine + content); | |
2918 | - return "Err:Json Parse Error(DataContractJsonSerializer)"; | |
2919 | - } | |
2920 | - catch(Exception ex) | |
2921 | - { | |
2922 | - MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); | |
2923 | - return "Err:Invalid Json!"; | |
2924 | - } | |
2925 | - } while (cursor != 0); | |
2926 | - | |
2927 | - TabInformations.GetInstance().SubscribableLists = lists; | |
2928 | - return ""; | |
2929 | - } | |
2930 | - | |
2931 | - private string GetListsApi11() | |
2932 | - { | |
2933 | 2549 | if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return ""; |
2934 | 2550 | |
2935 | 2551 | HttpStatusCode res; |
@@ -2938,7 +2554,7 @@ namespace OpenTween | ||
2938 | 2554 | |
2939 | 2555 | try |
2940 | 2556 | { |
2941 | - res = twCon.GetLists(this.Username, null, ref content); | |
2557 | + res = twCon.GetLists(this.Username, ref content); | |
2942 | 2558 | } |
2943 | 2559 | catch (Exception ex) |
2944 | 2560 | { |
@@ -2966,7 +2582,7 @@ namespace OpenTween | ||
2966 | 2582 | |
2967 | 2583 | try |
2968 | 2584 | { |
2969 | - res = twCon.GetListsSubscriptions(this.Username, null, ref content); | |
2585 | + res = twCon.GetListsSubscriptions(this.Username, ref content); | |
2970 | 2586 | } |
2971 | 2587 | catch (Exception ex) |
2972 | 2588 | { |
@@ -3509,43 +3125,7 @@ namespace OpenTween | ||
3509 | 3125 | } |
3510 | 3126 | } |
3511 | 3127 | |
3512 | - public TwitterApiStatus GetInfoApi10() | |
3513 | - { | |
3514 | - if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return null; | |
3515 | - | |
3516 | - if (MyCommon._endingFlag) return null; | |
3517 | - | |
3518 | - HttpStatusCode res; | |
3519 | - var content = ""; | |
3520 | - try | |
3521 | - { | |
3522 | - res = twCon.RateLimitStatus(ref content); | |
3523 | - } | |
3524 | - catch(Exception) | |
3525 | - { | |
3526 | - this.ResetApiStatus(); | |
3527 | - return null; | |
3528 | - } | |
3529 | - | |
3530 | - var err = this.CheckStatusCode(res, content); | |
3531 | - if (err != null) return null; | |
3532 | - | |
3533 | - try | |
3534 | - { | |
3535 | - var limit = MyCommon.CreateDataFromJson<TwitterDataModel.RateLimitStatus>(content); | |
3536 | - MyCommon.TwitterApiInfo.UpdateFromApi(limit); | |
3537 | - | |
3538 | - return MyCommon.TwitterApiInfo; | |
3539 | - } | |
3540 | - catch(Exception ex) | |
3541 | - { | |
3542 | - MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content); | |
3543 | - MyCommon.TwitterApiInfo.Reset(); | |
3544 | - return null; | |
3545 | - } | |
3546 | - } | |
3547 | - | |
3548 | - public TwitterApiStatus11 GetInfoApi11() | |
3128 | + public TwitterApiStatus GetInfoApi() | |
3549 | 3129 | { |
3550 | 3130 | if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return null; |
3551 | 3131 |
@@ -3568,8 +3148,8 @@ namespace OpenTween | ||
3568 | 3148 | |
3569 | 3149 | try |
3570 | 3150 | { |
3571 | - MyCommon.TwitterApiInfo11.UpdateFromJson(content); | |
3572 | - return MyCommon.TwitterApiInfo11; | |
3151 | + MyCommon.TwitterApiInfo.UpdateFromJson(content); | |
3152 | + return MyCommon.TwitterApiInfo; | |
3573 | 3153 | } |
3574 | 3154 | catch (Exception ex) |
3575 | 3155 | { |