ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 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")) ~~~ 该示例包含有关使用异步方法,更新对象和设置简单实现的详细信息。