zanysoft / laravel-hubspot
为 Hubspot API V1 客户端包添加了 Laravel 特定的包装器
1.0.0
2021-11-22 15:00 UTC
Requires
- php: ^7.0 || ^8
- hubspot/hubspot-php: ^3.0
- illuminate/support: ^5.8|^6.0|^7.0|^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15
- orchestra/testbench: >=3.4
README
这是一个 hubspot/hubspot-php 包的包装器,并为用户提供了一个 Service Container 绑定和 SevenShores\Hubspot\Factory::create('api-key')
函数的 facade。
安装
在命令行运行
composer require zanysoft/laravel-hubspot
配置
在命令行运行此命令以发布配置文件到 config/meta-tags.php
。
php artisan vendor:publish --provider="ZanySoft\LaravelHubSpot\HubSpotServiceProvider" --tag="config"
从您的 HubSpot 账户的集成页面获取 HubSpot API 密钥。
将您的 HubSpot API 密钥添加到您的 .env
文件中:HUBSPOT_API_KEY=yourApiKey
使用方法
您可以使用 facade 或将 HubSpot 类注入为依赖项
Facade
// Echo all contacts first and last names $response = HubSpot::contacts()->all(); foreach ($response->contacts as $contact) { echo sprintf( "Contact name is %s %s." . PHP_EOL, $contact->properties->firstname->value, $contact->properties->lastname->value ); } // OR $factory = HubSpot::factory(); $response = $factory->contacts()->all(); foreach ($response->contacts as $contact) { echo sprintf( "Contact name is %s %s." . PHP_EOL, $contact->properties->firstname->value, $contact->properties->lastname->value ); }
依赖注入
Route::get('/', function (ZanySoft\LaravelHubSpot\HubSpot $hubspot) { $response = $hubspot->contacts()->all(); foreach ($response->contacts as $contact) { echo sprintf( "Contact name is %s %s." . PHP_EOL, $contact->properties->firstname->value, $contact->properties->lastname->value ); } });
有关使用实际 API 的更多信息,请参阅主仓库 hubspot/hubspot-php
问题
请在此处仅报告与 Laravel 相关的问题,主要 API 问题应在此处报告 here