lobrs/calendly-sdk-php
Composer 安装命令:
composer require lobrs/calendly-sdk-php
包简介
Calendly API SDK PHP
README 文档
README
PHP implementation of Calendly API (v2).
Installation
composer require lobrs/calendly-sdk-php
Usage
\LoBrs\Calendly\Calendly::setToken($token); $currentUser = \LoBrs\Calendly\Calendly::me();
Get user from UUID
$user = \LoBrs\Calendly\Models\User::get($uuid);
Get model list
Returns an array of objects from the model class.
// List scheduled events from a user $scheduled_events = \Calendly\Models\Event::getList([ "user" => $user->uri ]); // List busy times from a user $busy_times = \Calendly\Models\UserBusyTime::getList([ "user" => $user->uri, "start_time" => date(DateTime::ATOM, strtotime("+1 minute")), "end_time" => date(DateTime::ATOM, strtotime("+7 days")), ]);
You can also use paginate($options) method, returning a PaginatedList.
$result = \Calendly\Models\Event::paginate([ "user" => $user->uri ]); echo $result->countResults() . " results \n"; echo $result->getNextPageURL(); // Request next page with the same options. $next_page_results = $result->next();
Refer to the Calendly API documentation to find requests options.
Currently supported models
| Models | Get uuid | Paginate | Create | Delete |
|---|---|---|---|---|
| Event | ✓ | ✓ | ||
| EventType | ✓ | ✓ | ||
| EventTypeAvailableTime | ✓ | |||
| Guest | ✓ | |||
| Invitee | ✓ | |||
| Organization | ✓ | |||
| OrganizationInvitation | ✓ | |||
| OrganizationMembership | ✓ | ✓ | ||
| Profile | ✓ | |||
| RoutingForm | ✓ | ✓ | ||
| RoutingFormSubmission | ✓ | ✓ | ||
| SchedulingLink | ✓ | ✓ | ||
| User | ✓ | |||
| UserAvailabilitySchedule | ✓ | |||
| UserBusyTime | ✓ | |||
| WebhookSubscription | ✓ | ✓ | ✓ | ✓ |
Direct API request usage
You can directly call the API using Calendly::request($uri, "GET", $params), which returns the body of the response.
Webhooks
You can use WebhookSubscription Model directly to manage your Webhooks methods getList, get, create and delete.
Webhook subscription
We provide the subscribe helper method to add a new webhook.
The 3rd parameter can be a $uuid referencing a user or organization uuid or an array of options.
\LoBrs\Calendly\Webhooks\Webhook::subscribe("https://example.com/my-webhook", [ 'invitee.created' ], [ 'user' => 'user_abc123', 'organization' => 'organization_abc123', 'scope' => 'organization', ], 'my-webhook-secret-key');
To improve security, you can sign your webhooks by providing the webhook secret key parameter.
Webhook payload example
$payload = @file_get_contents('php://input'); $header = $_SERVER['HTTP_CALENDLY_WEBHOOK_SIGNATURE']; try { $webhook = Webhook::readEvent($payload, $header, 'my-webhook-secret-key'); } catch (WebhookExpiredResponseException|WebhookSignatureException $e) {}
OAuth
This package comes with an OAuth2 CLient, using ThePhpLeague OAuth2 Client
Usage flow
$provider = new CalendlyOAuthProvider([ "clientId" => env('CALENDLY_CLIENT'), "clientSecret" => env('CALENDLY_OAUTH_SECRET'), 'redirectUri' => env('CALENDLY_REDIRECT_URI'), ]); if (!isset($_GET['code'])) { // If we don't have an authorization code then get one $authUrl = $provider->getAuthorizationUrl(); header('Location: ' . $authUrl); exit; } else { // Try to get an access token (using the authorization code grant) $token = $provider->getAccessToken('authorization_code', [ 'code' => $_GET['code'], ]); try { // We got an access token, let's now get the user's details $user = $provider->getResourceOwner($token); print_r($user->toArray()); } catch (Exception $e) { exit('Failed to get user details'); } // Use this to interact with an API on the users behalf echo $token->getToken(); }
lobrs/calendly-sdk-php 适用场景与选型建议
lobrs/calendly-sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40.79k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2022 年 05 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lobrs/calendly-sdk-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lobrs/calendly-sdk-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 40.79k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-18