Last active
January 3, 2016 11:29
-
-
Save upsilon/8456720 to your computer and use it in GitHub Desktop.
Tween1100相当の Thumbnail.vb にDM添付画像をサムネイル表示するコードを書いたら多分こんな感じ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ' コンパイルも通してない適当コード | |
| ' 参考: https://github.com/opentween/OpenTween/blob/456c6d3b30a6731b1b9dde151da4a4d1752fad5f/OpenTween/Thumbnail/Services/TonTwitterCom.cs | |
| Private Function TonTwitterCom_GetUrl(ByVal args As GetUrlArgs) As Boolean | |
| Dim url As String = If(String.IsNullOrEmpty(args.extended), args.url, args.extended) | |
| Return url.StartsWith("https://ton.twitter.com/1.1/ton/data/") | |
| End Function | |
| Private Function TonTwitterCom_CreateImage(ByVal args As CreateImageArgs) As Boolean | |
| Dim oauth As New HttpOAuthApiProxy() | |
| oauth.Initialize(<<<ConsumerKey>>>, <<<ConsumerSecret>>>, | |
| Owner.tw.AccessToken, Owner.tw.AccessTokenSecret, "", "") | |
| Dim responseStream As Stream = Nothing | |
| Dim userAgent As String = My.Application.Info.AssemblyName & "/" & MyCommon.fileVersion & " (compatible; MSIE 10.0)" | |
| Dim statusCode As HttpStatusCode = oauth.GetContent("GET", New Uri(args.url.Value), Nothing, response, userAgent) | |
| Using responseStream | |
| If statusCode = HttpStatusCode.OK Then | |
| Dim img As Bitmap | |
| Try | |
| img = New Bitmap(responseStream) | |
| args.pics.Add(New KeyValuePair(Of String, Image)(args.url.Key, img)) | |
| args.tooltipText.Add(New KeyValuePair(Of String, String)(args.url.Key, "")) | |
| Return True | |
| Catch ex As Exception | |
| If img IsNot Nothing Then | |
| img.Dispose() | |
| End If | |
| args.errmsg = ex.ToString() | |
| End Try | |
| Else | |
| args.errmsg = statusCode.ToString() | |
| End If | |
| End Using | |
| Return False | |
| End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment