tombroucke/twenty-api
最新稳定版本:1.1.1
Composer 安装命令:
composer require tombroucke/twenty-api
包简介
REST API connector for twenty CRM
README 文档
README
Install
composer require tombroucke/twenty-api
Usage
This library is based on Fansipan.
There are a variety of convenient methods to inspect the response.
$response->body(): string; $response->data(): array; $response->status(): int; $response->ok(): bool; $response->successful(): bool; $response->failed(): bool; $response->header(string $header): ?string; $response->headers(): array; // and more...
Requests
There are currently 6 types of requests: CreateManyObjectsRequest, CreateObjectRequest, DeleteObjectRequest, FindManyObjectsRequest, FindObjectRequest and UpdateObjectRequest.
As a convention, the first argument of the constructor is always the object's API Name.
In requests to endpoints for single objects, the next argument is the object ID. In POST requests (CreateManyObjectsRequest, CreateObjectRequest, UpdateObjectRequest), the next argument is the post body. The next arguments can be query parameters. For readability, you can use named arguments.
new \Otomaties\Twenty\FindManyObjectsRequest( objectApiName: 'people', filter: 'companyId[eq]:12345678-ab12-12a3-12a3-a12b4c5678d9', startingAfter: 'eyJpZCI7GgHqLsjkE8A7RTblNGYaNDhhMy87ZqhePDOJB8VxZGFiZGIxMyJ7' )
Examples
Find Many Objects
<?php require dirname(__DIR__) . '/vendor/autoload.php'; $connector = new \Otomaties\Twenty\TwentyConnector( apiKey: 'xxx', baseUri: 'https://example.com' ); $request = new \Otomaties\Twenty\FindManyObjectsRequest('people'); $response = $connector->send($request); var_dump( $response->data() );
Create Many Objects
<?php require dirname(__DIR__) . '/vendor/autoload.php'; $connector = new \Otomaties\Twenty\TwentyConnector( apiKey: 'xxx', baseUri: 'https://example.com' ); $objects = [ [ 'name' => [ 'firstName' => 'John', 'lastName' => 'Doe', ], ], [ 'name' => [ 'firstName' => 'Jane', 'lastName' => 'Doe', ], ], ]; $request = new \Otomaties\Twenty\CreateManyObjectsRequest('people', $objects); $response = $connector->send($request); var_dump( $response->data() );
Metadata
<?php require dirname(__DIR__) . '/vendor/autoload.php'; $connector = new \Otomaties\Twenty\TwentyConnector( apiKey: 'xxx', baseUri: 'https://example.com' ); $request = new \Otomaties\Twenty\Metadata\ObjectsRequest(); $response = $connector->send($request); var_dump( $response->data() );
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-07-02