// for more details.
//
// You should have received a copy of the GNU General public License along
-// with this program. if (not, see <http://www.gnu.org/licenses/>, or write to
+// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
// Boston, MA 02110-1301, USA.
private const string AuthorizeUrl = "https://api.twitter.com/oauth/authorize";
private const string AccessTokenUrl = "https://api.twitter.com/oauth/access_token";
- private static string _protocol = "http://";
-
private const string PostMethod = "POST";
private const string GetMethod = "GET";
private IHttpConnection httpCon; //HttpConnectionApi or HttpConnectionOAuth
- private HttpVarious httpConVar = new HttpVarious();
private enum AuthMethod
{
this.Initialize("", "", "", 0);
}
- public static bool UseSsl
- {
- set
- {
- if (value)
- _protocol = "https://";
- else
- _protocol = "http://";
- }
- }
-
- public HttpStatusCode UpdateStatus(string status, long? replyToId, ref string content)
+ public HttpStatusCode UpdateStatus(string status, long? replyToId, List<long> mediaIds, ref string content)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param.Add("status", status);
param.Add("include_entities", "true");
//if (AppendSettingDialog.Instance.ShortenTco && AppendSettingDialog.Instance.UrlConvertAuto) param.Add("wrap_links", "true")
+ if (mediaIds != null && mediaIds.Count > 0)
+ param.Add("media_ids", string.Join(",", mediaIds));
+
return httpCon.GetContent(PostMethod,
this.CreateTwitterUri("/1.1/statuses/update.json"),
param,
param,
binary,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/statuses/update_with_media"));
}
+ public HttpStatusCode UploadMedia(FileInfo mediaFile, ref string content)
+ {
+ //画像投稿専用エンドポイント
+ List<KeyValuePair<string, FileInfo>> binary = new List<KeyValuePair<string, FileInfo>>();
+ binary.Add(new KeyValuePair<string, FileInfo>("media", mediaFile));
+
+ return httpCon.GetContent(PostMethod,
+ this.CreateTwitterUploadUri("/1.1/media/upload.json"),
+ null,
+ binary,
+ ref content,
+ null,
+ null);
+ }
+
public HttpStatusCode DestroyStatus(long id)
{
string content = null;
this.CreateTwitterUri("/1.1/users/show.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/users/show/:id"));
}
this.CreateTwitterUri("/1.1/friendships/show.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/friendships/show"));
}
this.CreateTwitterUri("/1.1/statuses/show/" + id + ".json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/statuses/show/:id"));
}
this.CreateTwitterUri("/1.1/statuses/home_timeline.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/statuses/home_timeline"));
}
this.CreateTwitterUri("/1.1/statuses/user_timeline.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/statuses/user_timeline"));
}
this.CreateTwitterUri("/1.1/statuses/mentions_timeline.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/statuses/mentions_timeline"));
}
this.CreateTwitterUri("/1.1/direct_messages.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/direct_messages"));
}
this.CreateTwitterUri("/1.1/direct_messages/sent.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/direct_messages/sent"));
}
this.CreateTwitterUri("/1.1/favorites/list.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/favorites/list"));
}
this.CreateTwitterUri("/1.1/search/tweets.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/search/tweets"));
}
this.CreateTwitterUri("/1.1/saved_searches/list.json"),
null,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/saved_searches/list"));
}
this.CreateTwitterUri("/1.1/followers/ids.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/followers/ids"));
}
this.CreateTwitterUri("/1.1/friendships/no_retweets/ids.json"),
null,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/friendships/no_retweets/ids"));
}
this.CreateTwitterUri("/1.1/application/rate_limit_status.json"),
null,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/application/rate_limit_status"));
}
this.CreateTwitterUri("/1.1/lists/list.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/lists/list"));
}
this.CreateTwitterUri("/1.1/lists/subscriptions.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/lists/subscriptions"));
}
this.CreateTwitterUri("/1.1/lists/statuses.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/lists/statuses"));
}
this.CreateTwitterUri("/1.1/lists/members.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/lists/members"));
}
this.CreateTwitterUri("/1.1/lists/members/show.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/lists/members/show"));
}
#endregion
this.CreateTwitterUri("/1.1/statuses/retweeters/ids.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/statuses/retweeters/ids"));
}
this.CreateTwitterUri("/1.1/blocks/ids.json"),
param,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/blocks/ids"));
}
+ public HttpStatusCode GetMuteUserIds(ref string content, long? cursor)
+ {
+ var param = new Dictionary<string, string>();
+
+ if (cursor != null)
+ param.Add("cursor", cursor.ToString());
+
+ return httpCon.GetContent(GetMethod,
+ this.CreateTwitterUri("/1.1/mutes/users/ids.json"),
+ param,
+ ref content,
+ this.CreateRatelimitHeadersDict(),
+ this.CreateApiCalllback("/1.1/mutes/users/ids"));
+ }
+
public HttpStatusCode GetConfiguration(ref string content)
{
return httpCon.GetContent(GetMethod,
this.CreateTwitterUri("/1.1/help/configuration.json"),
null,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/help/configuration"));
}
this.CreateTwitterUri("/1.1/account/verify_credentials.json"),
null,
ref content,
- this.CreateRetelimitHeadersDict(),
+ this.CreateRatelimitHeadersDict(),
this.CreateApiCalllback("/account/verify_credentials"));
}
private static string _twitterUrl = "api.twitter.com";
private static string _twitterUserStreamUrl = "userstream.twitter.com";
private static string _twitterStreamUrl = "stream.twitter.com";
+ private static string _twitterUploadUrl = "upload.twitter.com";
private Uri CreateTwitterUri(string path)
{
- return new Uri(string.Format("{0}{1}{2}", _protocol, _twitterUrl, path));
+ return new Uri(string.Format("{0}{1}{2}", "https://", _twitterUrl, path));
}
private Uri CreateTwitterUserStreamUri(string path)
return new Uri(string.Format("{0}{1}{2}", "http://", _twitterStreamUrl, path));
}
+ private Uri CreateTwitterUploadUri(string path)
+ {
+ return new Uri(string.Format("{0}{1}{2}", "https://", _twitterUploadUrl, path));
+ }
+
public static string TwitterUrl
{
set
}
#endregion
- private Dictionary<string, string> CreateRetelimitHeadersDict()
+ private Dictionary<string, string> CreateRatelimitHeadersDict()
{
return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{