# 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编码