• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

OpenTweenのfork


Commit MetaInfo

修订版9a5be64af84ae3ca4bd27282c0657ca6b8ea27cf (tree)
时间2012-06-17 22:38:54
作者re4k <re4k@re4k...>
Commiterre4k

Log Message

発言のRetweet回数を取得できるようにした

更改概述

差异

--- a/OpenTween/Twitter.cs
+++ b/OpenTween/Twitter.cs
@@ -1293,62 +1293,55 @@ namespace OpenTween
12931293
12941294 public string GetStatus_Retweeted_Count(long StatusId, ref int retweeted_count)
12951295 {
1296- if (MyCommon._endingFlag) return "";
1297-
12981296 if (Twitter.AccountState != MyCommon.ACCOUNT_STATE.Valid) return "";
12991297
1298+ if (MyCommon._endingFlag) return "";
1299+
13001300 HttpStatusCode res = HttpStatusCode.BadRequest;
13011301 var content = "";
13021302
1303- retweeted_count = 0;
1304-
1305- // 注:dev.twitter.comに記述されているcountパラメータは間違い。100が正しい
1306- for (int i = 1; i <= 100; i++)
1303+ try
13071304 {
1308- try
1309- {
1310- res = twCon.Statusid_retweeted_by_ids(StatusId, 100, i, ref content);
1311- }
1312- catch(Exception ex)
1313- {
1314- return "Err:" + ex.Message;
1315- }
1305+ res = twCon.ShowStatuses(StatusId, ref content);
1306+ }
1307+ catch (Exception ex)
1308+ {
1309+ return "Err:" + ex.Message;
1310+ }
1311+ switch (res)
1312+ {
1313+ case HttpStatusCode.OK:
1314+ Twitter.AccountState = MyCommon.ACCOUNT_STATE.Valid;
1315+ break;
1316+ case HttpStatusCode.Unauthorized:
1317+ Twitter.AccountState = MyCommon.ACCOUNT_STATE.Invalid;
1318+ return Properties.Resources.Unauthorized;
1319+ case HttpStatusCode.BadRequest:
1320+ return "Err:API Limits?";
1321+ case HttpStatusCode.Forbidden:
1322+ return "Err:protected user's tweet";
1323+ default:
1324+ return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")";
1325+ }
13161326
1317- switch (res)
1318- {
1319- case HttpStatusCode.OK:
1320- try
1321- {
1322- var ids = MyCommon.CreateDataFromJson<Int64[]>(content);
1323- retweeted_count += ids.Length;
1324- if (ids.Length < 100) goto exit_for;
1325- }
1326- catch (SerializationException ex)
1327- {
1328- retweeted_count = -1;
1329- MyCommon.TraceOut(ex.Message + Environment.NewLine + content);
1330- return "Err:Json Parse Error(DataContractJsonSerializer)";
1331- }
1332- catch (Exception ex)
1333- {
1334- retweeted_count = -1;
1335- MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
1336- return "Err:Invalid Json!";
1337- }
1338- break;
1339- case HttpStatusCode.BadRequest:
1340- retweeted_count = -1;
1341- return "Err:API Limits?";
1342- case HttpStatusCode.Unauthorized:
1343- retweeted_count = -1;
1344- Twitter.AccountState = MyCommon.ACCOUNT_STATE.Invalid;
1345- return Properties.Resources.Unauthorized;
1346- default:
1347- retweeted_count = -1;
1348- return "Err:" + res.ToString() + "(" + MethodBase.GetCurrentMethod().Name + ")";
1349- }
1327+ TwitterDataModel.Status status;
1328+ try
1329+ {
1330+ status = MyCommon.CreateDataFromJson<TwitterDataModel.Status>(content);
1331+ }
1332+ catch (SerializationException ex)
1333+ {
1334+ MyCommon.TraceOut(ex.Message + Environment.NewLine + content);
1335+ return "Json Parse Error(DataContractJsonSerializer)";
1336+ }
1337+ catch (Exception ex)
1338+ {
1339+ MyCommon.TraceOut(ex, MethodBase.GetCurrentMethod().Name + " " + content);
1340+ return "Invalid Json!";
13501341 }
1351- exit_for:
1342+ int tmp;
1343+ if (int.TryParse(status.RetweetCount, out tmp))
1344+ retweeted_count = tmp;
13521345 return "";
13531346 }
13541347