{
public class HttpTwitter : ICloneable
{
+ /// <summary>
+ /// API v1.1 を有効にする否か
+ /// </summary>
+ /// <remarks>
+ /// 旧APIが使用出来なくなったら消す予定。
+ /// 静的フィールドとしているのは TwitterUserstream クラスが Clone メソッドを使用しているため
+ /// </remarks>
+ public static bool API11Enabled { get; set; }
+
//OAuth関連
///<summary>
///OAuthのアクセストークン取得先URI
{"X-RateLimit-Limit", ""},
{"X-RateLimit-Remaining", ""},
{"X-RateLimit-Reset", ""},
+ {"X-Rate-Limit-Limit", ""},
+ {"X-Rate-Limit-Remaining", ""},
+ {"X-Rate-Limit-Reset", ""},
{"X-MediaRateLimit-Limit", ""},
{"X-MediaRateLimit-Remaining", ""},
{"X-MediaRateLimit-Reset", ""},
};
+ static HttpTwitter()
+ {
+ HttpTwitter.API11Enabled = true;
+ }
+
public void Initialize(string accessToken,
string accessTokenSecret,
string username,
//if (AppendSettingDialog.Instance.ShortenTco && AppendSettingDialog.Instance.UrlConvertAuto) param.Add("wrap_links", "true")
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/statuses/update.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/update.json" : "/1/statuses/update.json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode UpdateStatusWithMedia(string status, long replyToId, FileInfo mediaFile, ref string content)
binary.Add(new KeyValuePair<string, FileInfo>("media[]", mediaFile));
return httpCon.GetContent(PostMethod,
- new Uri("https://upload.twitter.com/1/statuses/update_with_media.json"),
- param,
- binary,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ HttpTwitter.API11Enabled ? CreateTwitterUri("/1.1/statuses/update_with_media.json") : new Uri("https://upload.twitter.com/1/statuses/update_with_media.json"),
+ param,
+ binary,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/update_with_media") : GetApiCallback);
}
public HttpStatusCode DestroyStatus(long id)
{
string content = null;
+ var param = new Dictionary<string, string>();
+ if (HttpTwitter.API11Enabled)
+ param.Add("id", id.ToString());
+
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/statuses/destroy/" + id.ToString()+ ".json"),
- null,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/destroy.json" : "/1/statuses/destroy/" + id + ".json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode SendDirectMessage(string status, string sendto, ref string content)
//if (AppendSettingDialog.Instance.ShortenTco && AppendSettingDialog.Instance.UrlConvertAuto) param.Add("wrap_links", "true")
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/direct_messages/new.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/direct_messages/new.json" : "/1/direct_messages/new.json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode DestroyDirectMessage(long id)
{
string content = null;
+ var param = new Dictionary<string, string>();
+ if (HttpTwitter.API11Enabled)
+ param.Add("id", id.ToString());
+
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/direct_messages/destroy/" + id.ToString()+ ".json"),
- null,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/direct_messages/destroy.json" : "/1/direct_messages/destroy/" + id + ".json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode RetweetStatus(long id, ref string content)
param.Add("include_entities", "true");
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/statuses/retweet/" + id.ToString() + ".json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/retweet/" + id + ".json" : "/1/statuses/retweet/" + id + ".json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode ShowUserInfo(string screenName, ref string content)
param.Add("screen_name", screenName);
param.Add("include_entities", "true");
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/users/show.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/users/show.json" : "/1/users/show.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/users/show/:id") : GetApiCallback);
}
public HttpStatusCode CreateFriendships(string screenName, ref string content)
param.Add("screen_name", screenName);
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/friendships/create.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/friendships/create.json" : "/1/friendships/create.json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode DestroyFriendships(string screenName, ref string content)
param.Add("screen_name", screenName);
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/friendships/destroy.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/friendships/destroy.json" : "/1/friendships/destroy.json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode CreateBlock(string screenName, ref string content)
param.Add("screen_name", screenName);
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/blocks/create.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/blocks/create.json" : "/1/blocks/create.json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode DestroyBlock(string screenName, ref string content)
param.Add("screen_name", screenName);
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/blocks/destroy.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/blocks/destroy.json" : "/1/blocks/destroy.json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode ReportSpam(string screenName, ref string content)
param.Add("screen_name", screenName);
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/report_spam.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/users/report_spam.json" : "/1/report_spam.json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode ShowFriendships(string souceScreenName, string targetScreenName, ref string content)
param.Add("target_screen_name", targetScreenName);
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/friendships/show.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/friendships/show.json" : "/1/friendships/show.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/friendships/show") : GetApiCallback);
}
public HttpStatusCode ShowStatuses(long id, ref string content)
Dictionary<string, string> param = new Dictionary<string, string>();
param.Add("include_entities", "true");
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/statuses/show/" + id.ToString() + ".json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/show/" + id + ".json" : "/1/statuses/show/" + id + ".json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/show/:id") : GetApiCallback);
}
public HttpStatusCode CreateFavorites(long id, ref string content)
{
+ var param = new Dictionary<string, string>();
+ if (HttpTwitter.API11Enabled)
+ param.Add("id", id.ToString());
+
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/favorites/create/" + id.ToString() + ".json"),
- null,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/favorites/create.json" : "/1/favorites/create/" + id + ".json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode DestroyFavorites(long id, ref string content)
{
+ var param = new Dictionary<string, string>();
+ if (HttpTwitter.API11Enabled)
+ param.Add("id", id.ToString());
+
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/favorites/destroy/" + id.ToString() + ".json"),
- null,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/favorites/destroy.json" : "/1/favorites/destroy/" + id + ".json"),
+ null,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode HomeTimeline(int count, long max_id, long since_id, ref string content)
param.Add("include_entities", "true");
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/statuses/home_timeline.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/home_timeline.json" : "/1/statuses/home_timeline.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/home_timeline") : GetApiCallback);
}
public HttpStatusCode UserTimeline(long user_id, string screen_name, int count, long max_id, long since_id, ref string content)
param.Add("include_entities", "true");
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/statuses/user_timeline.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/user_timeline.json" : "/1/statuses/user_timeline.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/user_timeline") : GetApiCallback);
}
public HttpStatusCode PublicTimeline(int count, long max_id, long since_id, ref string content)
param.Add("include_entities", "true");
+ // TODO: API v1.1 に存在しない API (旧 API で代替)
+
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/statuses/public_timeline.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri("/1/statuses/public_timeline.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ GetApiCallback);
}
public HttpStatusCode Mentions(int count, long max_id, long since_id, ref string content)
param.Add("include_entities", "true");
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/statuses/mentions.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/statuses/mentions_timeline.json" : "/1/statuses/mentions.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/statuses/mentions_timeline") : GetApiCallback);
}
public HttpStatusCode DirectMessages(int count, long max_id, long since_id, ref string content)
param.Add("include_entities", "true");
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/direct_messages.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/direct_messages.json" : "/1/direct_messages.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/direct_messages") : GetApiCallback);
}
public HttpStatusCode DirectMessagesSent(int count, long max_id, long since_id, ref string content)
param.Add("include_entities", "true");
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/direct_messages/sent.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/direct_messages/sent.json" : "/1/direct_messages/sent.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/direct_messages/sent") : GetApiCallback);
}
public HttpStatusCode Favorites(int count, int page, ref string content)
param.Add("include_entities", "true");
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/favorites.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/favorites/list.json" : "/1/favorites.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/favorites/list") : GetApiCallback);
}
public HttpStatusCode PhoenixSearch(string querystr, ref string content)
MyCommon.GetAssemblyName());
}
- public HttpStatusCode Search(string words, string lang, int rpp, int page, long sinceId, ref string content)
+ public HttpStatusCode Search(string words, string lang, int count, int page, long sinceId, ref string content)
{
Dictionary<string, string> param = new Dictionary<string, string>();
if (!string.IsNullOrEmpty(words)) param.Add("q", words);
if (!string.IsNullOrEmpty(lang)) param.Add("lang", lang);
- if (rpp > 0) param.Add("rpp", rpp.ToString());
+ if (count > 0) param.Add(HttpTwitter.API11Enabled ? "count" : "rpp", count.ToString());
if (page > 0) param.Add("page", page.ToString());
if (sinceId > 0) param.Add("since_id", sinceId.ToString());
param.Add("result_type", "recent");
param.Add("include_entities", "true");
- return httpConVar.GetContent(GetMethod,
- this.CreateTwitterSearchUri("/search.json"),
- param,
- out content,
- null,
- MyCommon.GetAssemblyName());
+ return httpCon.GetContent(GetMethod,
+ HttpTwitter.API11Enabled ? this.CreateTwitterUri("/1.1/search/tweets.json") : this.CreateTwitterSearchUri("/search.json"),
+ param,
+ ref content,
+ null,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/search/tweets") : GetApiCallback);
}
public HttpStatusCode SavedSearches(ref string content)
{
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/saved_searches.json"),
- null,
- ref content,
- null,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/saved_searches/list.json" : "/1/saved_searches.json"),
+ null,
+ ref content,
+ null,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/saved_searches/list") : GetApiCallback);
}
public HttpStatusCode FollowerIds(long cursor, ref string content)
param.Add("cursor", cursor.ToString());
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/followers/ids.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/followers/ids.json" : "/1/followers/ids.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/followers/ids") : GetApiCallback);
}
public HttpStatusCode NoRetweetIds(long cursor, ref string content)
param.Add("cursor", cursor.ToString());
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/friendships/no_retweet_ids.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/friendships/no_retweets/ids.json" : "/1/friendships/no_retweet_ids.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/friendships/no_retweets/ids") : GetApiCallback);
}
public HttpStatusCode RateLimitStatus(ref string content)
{
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/account/rate_limit_status.json"),
- null,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/application/rate_limit_status.json" : "/1/account/rate_limit_status.json"),
+ null,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/application/rate_limit_status") : GetApiCallback);
}
#region Lists
param.Add("screen_name", user);
param.Add("cursor", cursor.ToString());
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/lists.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/list.json" : "/1/lists.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/list") : GetApiCallback);
}
public HttpStatusCode UpdateListID(string user, string list_id, string name, Boolean isPrivate, string description, ref string content)
if (description != null) param.Add("description", description);
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/lists/update.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/update.json" : "/1/lists/update.json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode DeleteListID(string user, string list_id, ref string content)
param.Add("list_id", list_id);
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/lists/destroy.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/destroy.json" : "/1/lists/destroy.json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode GetListsSubscriptions(string user, long cursor, ref string content)
param.Add("screen_name", user);
param.Add("cursor", cursor.ToString());
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/lists/subscriptions.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/subscriptions.json" : "/1/lists/subscriptions.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/subscriptions") : GetApiCallback);
}
public HttpStatusCode GetListsStatuses(long userId, long list_id, int per_page, long max_id, long since_id, Boolean isRTinclude, ref string content)
Dictionary<string, string> param = new Dictionary<string, string>();
param.Add("user_id", userId.ToString());
param.Add("list_id", list_id.ToString());
- if (isRTinclude)
- param.Add("include_rts", "true");
+ param.Add("include_rts", isRTinclude ? "true" : "false");
if (per_page > 0)
param.Add("per_page", per_page.ToString());
if (max_id > 0)
param.Add("include_entities", "true");
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/lists/statuses.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/statuses.json" : "/1/lists/statuses.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/statuses") : GetApiCallback);
}
public HttpStatusCode CreateLists(string listname, Boolean isPrivate, string description, ref string content)
param.Add("description", description);
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/lists/create.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/create.json" : "/1/lists/create.json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode GetListMembers(string user, string list_id, long cursor, ref string content)
param.Add("list_id", list_id);
param.Add("cursor", cursor.ToString());
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/lists/members.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/members.json" : "/1/lists/members.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/members") : GetApiCallback);
}
public HttpStatusCode CreateListMembers(string list_id, string memberName, ref string content)
param.Add("list_id", list_id);
param.Add("screen_name", memberName);
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/lists/members/create.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/members/create.json" : "/1/lists/members/create.json"),
+ param,
+ ref content,
+ null,
+ null);
}
//public HttpStatusCode CreateListMembers(string user, string list_id, string memberName, ref string content)
param.Add("screen_name", memberName);
param.Add("list_id", list_id);
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/lists/members/destroy.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/members/destroy.json" : "/1/lists/members/destroy.json"),
+ param,
+ ref content,
+ null,
+ null);
}
//public HttpStatusCode DeleteListMembers(string user, string list_id, string memberName, ref string content)
param.Add("screen_name", memberName);
param.Add("list_id", list_id);
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/lists/members/show.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
- //return httpCon.GetContent(GetMethod,
- // CreateTwitterUri("/1/" + user + "/" + list_id + "/members/" + id + ".json"),
- // null,
- // ref content,
- // MyCommon.TwitterApiInfo.HttpHeaders,
- // GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/lists/members/show.json" : "/1/lists/members/show.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/lists/members/show") : GetApiCallback);
}
#endregion
if (page > 0)
param.Add("page", page.ToString());
+ // TODO: API v1.1 に存在しない API (旧 API で代替)
+
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/statuses/" + statusid.ToString()+ "/retweeted_by/ids.json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri("/1/statuses/" + statusid + "/retweeted_by/ids.json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ GetApiCallback);
}
public HttpStatusCode UpdateProfile(string name, string url, string location, string description, ref string content)
param.Add("include_entities", "true");
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/account/update_profile.json"),
- param,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/account/update_profile.json" : "/1/account/update_profile.json"),
+ param,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode UpdateProfileImage(FileInfo imageFile, ref string content)
binary.Add(new KeyValuePair<string, FileInfo>("image", imageFile));
return httpCon.GetContent(PostMethod,
- CreateTwitterUri("/1/account/update_profile_image.json"),
- null,
- binary,
- ref content,
- null,
- null);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/account/update_profile_image.json" : "/1/account/update_profile_image.json"),
+ null,
+ binary,
+ ref content,
+ null,
+ null);
}
public HttpStatusCode GetRelatedResults(long id, ref string content)
param.Add("include_entities", "true");
+ // TODO: API v1.1 に存在しない API (旧 API で代替)
+
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/related_results/show/" + id.ToString()+ ".json"),
- param,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri("/1/related_results/show/" + id + ".json"),
+ param,
+ ref content,
+ this.apiStatusHeaders,
+ GetApiCallback);
}
public HttpStatusCode GetBlockUserIds(ref string content)
{
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/blocks/blocking/ids.json"),
- null,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/blocks/ids.json" : "/1/blocks/blocking/ids.json"),
+ null,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/blocks/ids") : GetApiCallback);
}
public HttpStatusCode GetConfiguration(ref string content)
{
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/help/configuration.json"),
- null,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/help/configuration.json" : "/1/help/configuration.json"),
+ null,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/help/configuration") : GetApiCallback);
}
public HttpStatusCode VerifyCredentials(ref string content)
{
return httpCon.GetContent(GetMethod,
- CreateTwitterUri("/1/account/verify_credentials.json"),
- null,
- ref content,
- this.apiStatusHeaders,
- GetApiCallback);
+ CreateTwitterUri(HttpTwitter.API11Enabled ? "/1.1/account/verify_credentials.json" : "/1/account/verify_credentials.json"),
+ null,
+ ref content,
+ this.apiStatusHeaders,
+ HttpTwitter.API11Enabled ? CreateApi11Calllback("/account/verify_credentials") : GetApiCallback);
}
#region Proxy API
MyCommon.TwitterApiInfo.UpdateFromHeader(this.apiStatusHeaders);
}
+ private CallbackDelegate CreateApi11Calllback(string endpointName)
+ {
+ return (object sender, ref HttpStatusCode code, ref string content) =>
+ {
+ if (code < HttpStatusCode.InternalServerError)
+ MyCommon.TwitterApiInfo11.UpdateFromHeader(this.apiStatusHeaders, endpointName);
+ };
+ }
+
public HttpStatusCode UserStream(ref Stream content,
bool allAtReplies,
string trackwords,
param.Add("track", trackwords);
return httpCon.GetContent(GetMethod,
- CreateTwitterUserStreamUri("/2/user.json"),
- param,
- ref content,
- userAgent);
+ CreateTwitterUserStreamUri(HttpTwitter.API11Enabled ? "/1.1/user.json" : "/2/user.json"),
+ param,
+ ref content,
+ userAgent);
}
public HttpStatusCode FilterStream(ref Stream content,
param.Add("track", string.Join(",", trackwords.Split(" ".ToCharArray())));
return httpCon.GetContent(PostMethod,
- CreateTwitterStreamUri("/1/statuses/filter.json"),
- param,
- ref content,
- userAgent);
+ CreateTwitterStreamUri(HttpTwitter.API11Enabled ? "/1.1/statuses/filter.json" : "/1/statuses/filter.json"),
+ param,
+ ref content,
+ userAgent);
}
public void RequestAbort()