felixmaier1989 / hubspot-php
HubSpot PHP API 客户端
v1.1.2
2018-01-17 20:33 UTC
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- codeclimate/php-test-reporter: dev-master@dev
- phpspec/phpspec: ~2.0
- phpunit/phpunit: ~4.0
- dev-master
- 2.0.x-dev
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v1.0.0-rc.4
- v1.0.0-rc.3
- v1.0.0-rc.2
- v1.0.0-rc.1
- v0.9.11
- v0.9.10
- v0.9.9
- v0.9.8
- v0.9.7
- v0.9.6
- v0.9.5
- v0.9.4
- v0.9.3
- v0.9.2
- v0.9.1
- v0.9
- v0.2
- v0.1.1
- v0.1.0
- dev-daily-api-usage
- dev-update-companies-batch
- dev-php54-guzzle5
- dev-php53
- dev-develop
This package is auto-updated.
Last update: 2024-09-04 20:38:07 UTC
README
Hubspot API 客户端。这是我对 HubSpot/haPihP 的完美功能包装的后续版本。然而,这是一个完整的重写,并包含了一些新的 COS/v2 端点。
设置
Composer
composer require "ryanwinchester/hubspot-php:~1.0"
快速入门
使用工厂的示例
以下所有示例都假设这一步。
$hubspot = SevenShores\Hubspot\Factory::create('api-key'); // OR instantiate by passing a configuration array. // The only required value is the 'key' $hubspot = new SevenShores\Hubspot\Factory([ 'key' => 'demo', 'oauth' => false, // default 'base_url' => 'https://api.hubapi.com' // default ]);
注意:您可以通过将以下选项传递给客户端创建例程来阻止此包提供的任何错误处理:(也适用于 Factory::create()
和 Factory::createWithToken()
)
$hubspot = new SevenShores\Hubspot\Factory([ 'key' => 'demo', 'oauth' => false, // default 'base_url' => 'https://api.hubapi.com' // default ], null, [ 'http_errors' => false // pass any Guzzle related option to any request, e.g. throw no exceptions ], false // return Guzzle Response object for any ->request(*) call );
通过将 http_errors
设置为 false,您将完全不会收到任何异常,而只会收到纯响应。有关可能的选项,请参阅 http://docs.guzzlephp.org/en/latest/request-options.html。
获取单个联系人
$contact = $hubspot->contacts()->getByEmail("test@hubspot.com"); echo $contact->properties->email->value;
遍历所有联系人
// Get an array of 10 contacts // getting only the firstname and lastname properties // and set the offset to 123456 $response = $hubspot->contacts()->all([ 'count' => 10, 'property' => ['firstname', 'lastname'], 'vidOffset' => 123456, ]);
处理数据非常简单!
foreach ($response->contacts as $contact) { echo sprintf( "Contact name is %s %s." . PHP_EOL, $contact->properties->firstname->value, $contact->properties->lastname->value ); } // Info for pagination echo $response->{'has-more'}; echo $response->{'vid-offset'};
或者如果您喜欢使用数组访问?
foreach ($response['contacts'] as $contact) { echo sprintf( "Contact name is %s %s." . PHP_EOL, $contact['properties']['firstname']['value'], $contact['properties']['lastname']['value'] ); } // Info for pagination echo $response['has-more']; echo $response['vid-offset'];
现在带有实现 PSR-7 ResponseInterface 的响应方法
$response->getStatusCode() // 200; $response->getReasonPhrase() // 'OK'; // etc...
无工厂示例
<?php require 'vendor/autoload.php'; use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Resources\Contacts; $client = new Client(['key' => 'demo']); $contacts = new Contacts($client); $response = $contacts->all(); foreach ($response->contacts as $contact) { // }
状态
如果您看到了您想要但没有计划的内容,请创建一个 问题,我很有可能将其添加。
- 博客(COS)🆕
- 博客作者(COS)🆕
- 博客文章(COS)🆕
- 博客主题(COS)🆕
- 公司 🆕
- 公司属性 🆕
- 联系人
- 联系人列表
- 联系人属性
- 交易 🆕
- 电子邮件 🆕
- 电子邮件事件 🆕
- 参与度
- 事件(企业)🆕
- 文件(COS)🆕
- 表单
- 关键词
- 所有者
- 页面发布(COS)🆕
- 社交媒体
- 模板(COS)🆕
- 时间线 🆕
- 工作流程