# WebAsyncWrapper
WebClient和WebRequest包裝類,用于啟用回調式異步請求
*注意* 僅限Windows且僅限Excel,需要引用“Microsoft WinHTTP Services, version 5.1”
用法:
~~~vb
'// Module: Handler
Public Sub Simple(Response As WebResponse)
'// ...
End Sub
Public Sub WithArgs(Response As WebResponse, Args As Variant)
'// ...
End Sub
Dim Client As New WebClient
Client.BaseUrl = "https://api.example.com/v1/"
'// 包裝類需要客戶端執行請求
Dim Wrapper As New WebAsyncWrapper
Set Wrapper.Client = Client
Dim Request As New WebRequest
Request.Resource = "messages"
Wrapper.ExecuteAsync Request, "Handler.Simple"
'// -> Simple called later with response
'// 如果需要將狀態傳遞給回調,請使用CallbackArgs
Dim Args As Variant
Args = Array("abc", 123)
Wrapper.ExecuteAsync Request, "Handler.WithArgs", Args
'// -> WithArgs called later with response and args
~~~
- README
- 指南
- 概述
- GET Request
- WebRequest
- 屬性
- Resource
- Method
- Body
- Format
- RequestFormat
- ResponseFormat
- CustomRequestFormat
- CustomResponseFormat
- ContentType
- Accept
- ContentLength
- FormattedResource
- Cookies
- Headers
- QuerystringParams
- UrlSegments
- 方法
- AddHeader
- SetHeader
- AddUrlSegment
- AddQuerystringParam
- AddCookie
- AddBodyParameter
- CreateFromOptions
- WebClient
- 屬性
- BaseUrl
- Authenticator
- TimeoutMs
- ProxyServer
- ProxyBypassList
- ProxyUsername
- ProxyPassword
- EnableAutoProxy
- Insecure
- FollowRedirects
- 方法
- Execute
- GetJson
- PostJson
- SetProxy
- GetFullUrl
- WebResponse
- 屬性
- StatusCode
- StatusDescription
- Content
- Data
- Body
- Headers
- Cookies
- 方法
- Update
- WebHelpers
- 屬性
- WebStatusCode
- WebMethod
- WebFormat
- UrlEncodingMode
- EnableLogging
- 方法
- LogDebug
- LogWarning
- LogError
- LogRequest
- LogResponse
- Obfuscate
- ParseJson
- ConvertToJson
- ParseUrlEncoded
- ConvertToUrlEncoded
- ParseXml
- ConvertToXml
- ParseByFormat
- ConvertToFormat
- UrlEncode
- UrlDecode
- Base64Encode
- Base64Decode
- RegisterConverter
- JoinUrl
- UrlParts
- CloneDictionary
- CloneCollection
- CreateKeyValue
- FindInKeyValues
- AddOrReplaceInKeyValues
- FormatToMediaType
- MethodToName
- HMACSHA1
- HMACSHA256
- MD5
- CreateNonce
- IWebAuthenticator
- 方法
- BeforeExecute
- AfterExecute
- PrepareHttp
- PrepareCurl
- WebAsyncWrapper
- 屬性
- Client
- 方法
- ExecuteAsync
- 范例
- Salesforce網站
- Google APIs
- Todoist API
- 其他主題
- 調試
- 授權
- 實現自己的IWebAuthenticator
- Url編碼