kappafix / php-salesforce
PHP Salesforce REST API 包装器
1.0.2
2022-07-06 09:16 UTC
Requires
- php: >=7.0
- ext-json: *
- guzzlehttp/guzzle: >=6.2
This package is auto-updated.
Last update: 2024-09-06 14:10:56 UTC
README
分支自: nachitox/php-salesforce-rest-api
bjsmasth/php-salesforce-rest-api
Cleeng/php-salesforce-rest-api
jerkob/php-salesforce-rest-api-forked
安装
通过 composer
composer require kappafix/php-salesforce
入门指南
设置连接应用
- 登录您的 Salesforce 组织
- 点击右上角的设置
- 在构建部分点击
创建 > 应用
- 滚动到页面底部,然后在连接应用部分点击
新建
- 为远程应用输入以下详细信息
- 连接应用名称
- API 名称
- 联系邮箱
- 在 API 下拉菜单中启用 OAuth 设置
- 回调 URL
- 选择访问范围(如果您需要刷新令牌,请在此处指定)
- 点击保存
保存后,您将获得 消费者密钥 和 消费者密钥。更新您的配置文件,添加 consumerKey
和 consumerSecret
的值
设置
身份验证
/*save the config options in a config file*/ $options = [ 'grant_type' => 'password', 'client_id' => 'CONSUMERKEY', /* insert consumer key here */ 'client_secret' => 'CONSUMERSECRET', /* insert consumer secret here */ 'username' => 'SALESFORCE_USERNAME', /* insert Salesforce username here */ 'password' => 'SALESFORCE_PASSWORD' . 'SECURITY_TOKEN', /* insert Salesforce user password and security token here */ 'endPoint' => 'https://login.salesforce.com/', /* if you want to login to a Sandbox change the url to https://test.salesforce.com/ */ 'apiVersion' => 'v48.0' ]; $salesforce = new \Kappafix\Salesforce\SfCaller($options); /* if you need access token or instance url */ $accessToken = $salesforce->getAccessToken(); $instanceUrl = $salesforce->getInstanceUrl();
查询
$query = 'SELECT Id,Name FROM ACCOUNT LIMIT 100'; /* returns array with the queried data */ $data = $salesforce->query($query);
创建
$data = [ 'Name' => 'Some name', ]; /* returns the id of the created object */ $salesforce->Account->insert( $data);
更新
$new_data = [ 'Name' => 'another name', ]; /* returns statuscode */ $salesforce->Account->update($id, $new_data);
更新/插入
$new_data = [ 'Name' => 'another name', ]; /* returns statuscode */ $salesforce->Account->upsert( 'API Name/ Field Name', 'value', $new_data);
删除
$salesforce->Account->delete($id);
获取
$salesforce->Account->get($id);
描述
$salesforce->'Account'->describe();
自定义端点
$salesforce->Account->customEndpoint('apex/myCustomEndpoint', $data, 200);
变更日志
16.03.2021
- 更容易使用,特别是在您在代码的多个区域中使用它时
- 在 SalesforceFunctions 上添加了 SalesforceWrapper
- 添加了 SfCaller,用于语法 $salesforce->Object->method($arguments)
09.06.2021
- 错误修复