Changeset 33664
- Timestamp:
- 05/29/09 18:12:10 (4 years ago)
- Location:
- lang/vb2005/FuwaKumo/trunk/FuwaKumo
- Files:
-
- 2 added
- 3 modified
-
FuwaKumo.vbproj (modified) (1 diff)
-
StatusElement.vb (added)
-
WebAccessBase.vb (modified) (1 diff)
-
WebOAuth.vb (modified) (3 diffs)
-
WebTwitter.vb (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/vb2005/FuwaKumo/trunk/FuwaKumo/FuwaKumo.vbproj
r33647 r33664 74 74 <Compile Include="SettingNet.vb" /> 75 75 <Compile Include="SettingTwitter.vb" /> 76 <Compile Include="StatusElement.vb" /> 76 77 <Compile Include="WebAccessBase.vb" /> 77 78 <Compile Include="WebOAuth.vb" /> 79 <Compile Include="WebTwitter.vb" /> 78 80 </ItemGroup> 79 81 <ItemGroup> -
lang/vb2005/FuwaKumo/trunk/FuwaKumo/WebAccessBase.vb
r33647 r33664 128 128 Return CType(sr.ReadToEnd(), Object) 129 129 End Using 130 Case Else 131 Throw New System.ArgumentException("Type must String or Bitmap") 130 132 End Select 131 133 End Using -
lang/vb2005/FuwaKumo/trunk/FuwaKumo/WebOAuth.vb
r33647 r33664 13 13 End Sub 14 14 15 P rivate Shared Function OpenAuthorizePage() As Boolean15 Public Shared Function GetAuthorizePageUrl() As String 16 16 _requestToken = "" 17 17 18 18 Dim query As System.Collections.Specialized.NameValueCollection = GetOAuthToken(_oauthSetting.RequestTokenUrl) 19 If query Is Nothing Then Return False19 If query Is Nothing OrElse query.Count = 0 Then Return Nothing 20 20 21 21 _requestToken = query.Item("oauth_token") 22 22 23 Try 24 System.Diagnostics.Process.Start(String.Format("{0}?oauth_token={1}", _oauthSetting.AuthorizeUrl, _requestToken)) 25 Catch ex As Exception 26 End Try 27 28 Return True 23 Return String.Format("{0}?oauth_token={1}", _oauthSetting.AuthorizeUrl, _requestToken) 29 24 End Function 30 25 31 P rivateShared Function GetAccessToken() As Boolean26 Public Shared Function GetAccessToken() As Boolean 32 27 If String.IsNullOrEmpty(_requestToken) Then Return False 33 28 34 29 Dim query As System.Collections.Specialized.NameValueCollection = GetOAuthToken(_oauthSetting.AccessTokenUrl) 35 30 36 If query Is Nothing Then Return False31 If query Is Nothing OrElse query.Count = 0 Then Return False 37 32 38 33 _oauthSetting.Token = query.Item("oauth_token") … … 48 43 Dim statusCode As HttpStatusCode 49 44 Try 50 Dim response As String = GetText(request, statusCode)45 Dim response As String = WebAccessBase.GetText(request, statusCode) 51 46 If statusCode <> HttpStatusCode.OK OrElse String.IsNullOrEmpty(response) Then Return Nothing 52 47 Return ParseQueryString(response) … … 102 97 Return _random.Next(123400, 9999999).ToString 103 98 End Function 99 100 Protected Shared Function GetPage(ByVal url As String, _ 101 ByRef query As System.Collections.Generic.SortedList(Of String, String), _ 102 ByVal encode As System.Text.Encoding, _ 103 ByVal headerInfo As System.Collections.Specialized.NameValueCollection _ 104 ) As String 105 Dim request As HttpWebRequest = CreateRequestObject(WEBACCESS_REQ_TYPE.ReqGET, _ 106 New Uri(url), _ 107 query) 108 Return GetText(request, query, encode, headerInfo) 109 End Function 110 111 Protected Shared Function PostData(ByVal url As String, _ 112 ByRef query As System.Collections.Generic.SortedList(Of String, String), _ 113 ByVal encode As System.Text.Encoding, _ 114 ByVal headerInfo As System.Collections.Specialized.NameValueCollection _ 115 ) As String 116 Dim request As HttpWebRequest = CreateRequestObject(WEBACCESS_REQ_TYPE.ReqPOST, _ 117 New Uri(url), _ 118 query) 119 Return GetText(request, query, encode, headerInfo) 120 End Function 121 122 Private Overloads Shared Function GetText(ByVal webRequest As HttpWebRequest, _ 123 ByVal query As System.Collections.Generic.SortedList(Of String, String), _ 124 ByVal encode As System.Text.Encoding, _ 125 ByVal headerInfo As System.Collections.Specialized.NameValueCollection _ 126 ) As String 127 128 If _oauthSetting.Token = "" Then Throw New System.UnauthorizedAccessException("Unauthorized OAuth") 129 130 AppendOAuthInfo(webRequest, query, _oauthSetting.Token, _oauthSetting.TokenSecret) 131 132 Dim statusCode As HttpStatusCode 133 Dim response As String = WebAccessBase.GetText(webRequest, statusCode, encode, headerInfo) 134 135 If statusCode = HttpStatusCode.Unauthorized Then 136 _oauthSetting.ClearToken() 137 Throw New System.UnauthorizedAccessException("Unauthorized OAuth") 138 End If 139 140 If statusCode <> HttpStatusCode.OK OrElse String.IsNullOrEmpty(response) Then Return Nothing 141 Return response 142 End Function 104 143 End Class
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)