# Salesforce
將Salesforce與VBA-Web一起使用的示例包含在此項目的examples /文件夾中。 一些細節:
## [](https://github.com/VBA-tools/VBA-Web/wiki/Salesforce#authentication)Authentication授權
1. 使用[Setup Salesforce](https://github.com/VBA-tools/VBA-Web/blob/master/examples/salesforce/Setup%20Salesforce.md)中的說明獲取consumer key和secret
2. 使用[用戶名 - 密碼OAuth身份驗證流程](http://www.salesforce.com/us/developer/docs/api_rest/Content/intro_understanding_username_password_oauth_flow.htm),使用OAuth2Authenticator并按如下所示進行設置:
~~~vbnet
Dim Auth As New OAuth2Authenticator
Auth.Setup _
ClientId:="ConsumerKey", _
ClientSecret:="ConsumerSecret", _
Username:="Username", _
Password:="Password" & "SecurityToken"
Auth.SetupTokenUrl "https://login.salesforce.com/services/oauth2/token?grant_type=password"
Set Client.Authenticator = Auth
~~~
## [](https://github.com/VBA-tools/VBA-Web/wiki/Salesforce#generic-object-request)Generic Object Request通用對象請求
對象(帳戶,聯系人等)的請求通過一般的“sobjects”資源,因此可以創建通用對象請求。
~~~vbnet
Public Function ObjectRequest(ObjectName As String, ObjectId As String) As RestRequest
Dim Request As New WebRequest
Request.Resource = "services/data/{ApiVersion}/sobjects/{ObjectName}/{ObjectId}"
Request.AddUrlSegment "ApiVersion", "v26.0"
Request.AddUrlSegment "ObjectName", ObjectName
Request.AddUrlSegment "ObjectId", ObjectId
Set ObjectRequest = Request
End Function
'// e.g. Client.Execute(ObjectRequest("Account", "Id...12345"))
~~~
該示例包含有關使用異步方法,更新對象和設置簡單實現的詳細信息。
- 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編碼