OSDN Git Service

Twitter.PostStatusメソッドにattachmentUrl引数を追加
authorKimura Youichi <kim.upsilon@bucyou.net>
Mon, 26 Sep 2016 11:49:08 +0000 (20:49 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 11 Nov 2017 21:06:49 +0000 (06:06 +0900)
OpenTween.Tests/Api/TwitterApiTest.cs
OpenTween/Api/TwitterApi.cs
OpenTween/Connection/IMediaUploadService.cs
OpenTween/Connection/Imgur.cs
OpenTween/Connection/Mobypicture.cs
OpenTween/Connection/TwitterPhoto.cs
OpenTween/Tween.cs
OpenTween/Twitter.cs

index 6c50768..5a49f42 100644 (file)
@@ -223,6 +223,7 @@ namespace OpenTween.Api
                             { "media_ids", "10,20" },
                             { "auto_populate_reply_metadata", "true" },
                             { "exclude_reply_user_ids", "100,200" },
+                            { "attachment_url", "https://twitter.com/twitterapi/status/22634515958" },
                         })
                 )
                 .ReturnsAsync(LazyJson.Create(new TwitterStatus()));
@@ -230,7 +231,8 @@ namespace OpenTween.Api
                 twitterApi.apiConnection = mock.Object;
 
                 await twitterApi.StatusesUpdate("hogehoge", replyToId: 100L, mediaIds: new[] { 10L, 20L },
-                        autoPopulateReplyMetadata: true, excludeReplyUserIds: new[] { 100L, 200L })
+                        autoPopulateReplyMetadata: true, excludeReplyUserIds: new[] { 100L, 200L },
+                        attachmentUrl: "https://twitter.com/twitterapi/status/22634515958")
                     .IgnoreResponse()
                     .ConfigureAwait(false);
 
index 9d2130a..c4baee3 100644 (file)
@@ -127,7 +127,7 @@ namespace OpenTween.Api
         }
 
         public Task<LazyJson<TwitterStatus>> StatusesUpdate(string status, long? replyToId, IReadOnlyList<long> mediaIds,
-            bool? autoPopulateReplyMetadata = null, IReadOnlyList<long> excludeReplyUserIds = null)
+            bool? autoPopulateReplyMetadata = null, IReadOnlyList<long> excludeReplyUserIds = null, string attachmentUrl = null)
         {
             var endpoint = new Uri("statuses/update.json", UriKind.Relative);
             var param = new Dictionary<string, string>
@@ -146,6 +146,8 @@ namespace OpenTween.Api
                 param["auto_populate_reply_metadata"] = autoPopulateReplyMetadata.Value ? "true" : "false";
             if (excludeReplyUserIds != null && excludeReplyUserIds.Count > 0)
                 param["exclude_reply_user_ids"] = string.Join(",", excludeReplyUserIds);
+            if (attachmentUrl != null)
+                param["attachment_url"] = attachmentUrl;
 
             return this.apiConnection.PostLazyAsync<TwitterStatus>(endpoint, param);
         }
index f06b71f..11f2565 100644 (file)
@@ -73,7 +73,7 @@ namespace OpenTween.Connection
         /// メディアのアップロードとツイートの投稿を行います
         /// </summary>
         /// <exception cref="WebApiException"/>
-        Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems, long[] excludeReplyUserIds);
+        Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems, long[] excludeReplyUserIds, string attachmentUrl);
 
         /// <summary>
         /// 画像URLのために確保する必要のある文字数を返します
index 5568c10..32c173d 100644 (file)
@@ -98,7 +98,8 @@ namespace OpenTween.Connection
             return MaxFileSize;
         }
 
-        public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems, long[] excludeReplyUserIds)
+        public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems,
+            long[] excludeReplyUserIds, string attachmentUrl)
         {
             if (mediaItems == null)
                 throw new ArgumentNullException(nameof(mediaItems));
@@ -138,7 +139,7 @@ namespace OpenTween.Connection
 
             var textWithImageUrl = text + " " + imageUrl.Trim();
 
-            await this.twitter.PostStatus(textWithImageUrl, inReplyToStatusId, excludeReplyUserIds: excludeReplyUserIds)
+            await this.twitter.PostStatus(textWithImageUrl, inReplyToStatusId, excludeReplyUserIds: excludeReplyUserIds, attachmentUrl: attachmentUrl)
                 .ConfigureAwait(false);
         }
 
index 694527e..e8df241 100644 (file)
@@ -122,7 +122,8 @@ namespace OpenTween.Connection
             return MaxFileSize;
         }
 
-        public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems, long[] excludeReplyUserIds)
+        public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems,
+            long[] excludeReplyUserIds, string attachmentUrl)
         {
             if (mediaItems == null)
                 throw new ArgumentNullException(nameof(mediaItems));
@@ -147,7 +148,7 @@ namespace OpenTween.Connection
 
             var textWithImageUrl = text + " " + imageUrlElm.Value.Trim();
 
-            await this.twitter.PostStatus(textWithImageUrl, inReplyToStatusId, excludeReplyUserIds: excludeReplyUserIds)
+            await this.twitter.PostStatus(textWithImageUrl, inReplyToStatusId, excludeReplyUserIds: excludeReplyUserIds, attachmentUrl: attachmentUrl)
                 .ConfigureAwait(false);
         }
 
index e2416d5..41715c3 100644 (file)
@@ -78,7 +78,8 @@ namespace OpenTween.Connection
             return this.twitterConfig.PhotoSizeLimit;
         }
 
-        public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems, long[] excludeReplyUserIds)
+        public async Task PostStatusAsync(string text, long? inReplyToStatusId, IMediaItem[] mediaItems,
+            long[] excludeReplyUserIds, string attachmentUrl)
         {
             if (mediaItems == null)
                 throw new ArgumentNullException(nameof(mediaItems));
@@ -101,7 +102,7 @@ namespace OpenTween.Connection
             var mediaIds = await Task.WhenAll(uploadTasks)
                 .ConfigureAwait(false);
 
-            await this.tw.PostStatus(text, inReplyToStatusId, mediaIds, excludeReplyUserIds)
+            await this.tw.PostStatus(text, inReplyToStatusId, mediaIds, excludeReplyUserIds, attachmentUrl)
                 .ConfigureAwait(false);
         }
 
index 6ca4651..54913a8 100644 (file)
@@ -319,6 +319,7 @@ namespace OpenTween
             public long? inReplyToId = null;
             public string inReplyToName = null;
             public long[] excludeReplyUserIds = null;
+            public string attachmentUrl = null;
             public string imageService = "";      //画像投稿サービス名
             public IMediaItem[] mediaItems = null;
             public PostingStatus()
@@ -2763,13 +2764,13 @@ namespace OpenTween
                 {
                     if (status.mediaItems == null || status.mediaItems.Length == 0)
                     {
-                        await this.tw.PostStatus(status.status, status.inReplyToId, excludeReplyUserIds: status.excludeReplyUserIds)
+                        await this.tw.PostStatus(status.status, status.inReplyToId, excludeReplyUserIds: status.excludeReplyUserIds, attachmentUrl: status.attachmentUrl)
                             .ConfigureAwait(false);
                     }
                     else
                     {
                         var service = ImageSelector.GetService(status.imageService);
-                        await service.PostStatusAsync(status.status, status.inReplyToId, status.mediaItems, status.excludeReplyUserIds)
+                        await service.PostStatusAsync(status.status, status.inReplyToId, status.mediaItems, status.excludeReplyUserIds, status.attachmentUrl)
                             .ConfigureAwait(false);
                     }
                 });
index c263995..8166426 100644 (file)
@@ -279,7 +279,7 @@ namespace OpenTween
         }
 
         public async Task PostStatus(string postStr, long? reply_to, IReadOnlyList<long> mediaIds = null,
-            IReadOnlyList<long> excludeReplyUserIds = null)
+            IReadOnlyList<long> excludeReplyUserIds = null, string attachmentUrl = null)
         {
             this.CheckAccountState();
 
@@ -295,7 +295,7 @@ namespace OpenTween
                 autoPopulateReplyMetadata = true;
 
             var response = await this.Api.StatusesUpdate(postStr, reply_to, mediaIds,
-                    autoPopulateReplyMetadata, excludeReplyUserIds)
+                    autoPopulateReplyMetadata, excludeReplyUserIds, attachmentUrl)
                 .ConfigureAwait(false);
 
             var status = await response.LoadJsonAsync()