paravibe/gototraining

PHP的GoToTraining API包装器

1.0.4 2023-09-01 12:45 UTC

This package is auto-updated.

Last update: 2024-09-30 01:30:05 UTC


README

Latest Version Build Status Total Downloads

安装

composer require paravibe/gototraining

如何使用

初始化客户端

$client = new \LogMeIn\GoToTraining\Client($access_token, $values);

其中 $access_token 是在授权过程中获取的令牌 - https://developer.goto.com/guides/HowTos/03_HOW_accessToken/
以及 $values 是包含以下内容的响应数据:

  • account_key
  • account_type
  • email
  • firstName
  • lastName
  • organizer_key

通过将适当的HTTP方法和端点传递给createRequest()方法,使用此处描述的任何方法 https://developer.goto.com/GoToTrainingV1

GET/DELETE方法

$get = $client->createRequest('GET', "organizers/{$organizer_key}/trainings")->execute();
$data = $get->getDecodedBody();

POST/PUT方法

$post_data = array(
  'name' => 'Training',
  'description' => 'Test API integration',
  'times' => [
    [
      'startDate' => '2021-03-02T12:00:00Z',
      'endDate' => '2021-03-02T13:00:00Z',
    ]
  ],
  'timeZone' => 'Europe/Kiev',
);

$new = $client->createRequest('POST', "organizers/{$organizer_key}/trainings")
  ->attachBody($post_data)
  ->execute();