tcdev/thinkific-php

用于与Thinkific LMS API交互的PHP SDK

v1.0.0 2023-10-25 12:44 UTC

This package is auto-updated.

Last update: 2024-09-25 16:56:27 UTC


README

Dependency Status

此项目正在积极建设中,处于早期alpha阶段。它是一个SDK,可以帮助与Thinkific LMS API进行交互。该REST API的文档可以在这里找到。

安装

前沿技术

在您的开发过程中,您可以通过将thinkific-api的版本要求设置为dev-master来跟踪master分支的最新更改

{
   "require": {
      "elliotboney/thinkific-php": "dev-master"
   }
}

通过命令行

composer require elliotboney/thinkific-php

用法

创建用于与API交互的客户端

$think = new \Thinkific\Thinkific ( [
   'apikey'    => 'your-api-key',
   'subdomain' => 'yoursubdomain',
   'debug'     => true
   ] );

端点

您可以通过以下方案访问以下端点

  • 捆绑包
  • 集合
  • 优惠券
  • 课程评价
  • 课程
  • 报名
  • 订单
  • 产品
  • 促销
  • 用户

使用以下方案

// Create interface to access Users endpoint
$users = $think->users();

// Create interface to access Bundles endpoint
$bundles = $think->bundles();
// etc, etc

方法

类包含GET、PUT、POST、DELETE等基本请求,以及具有ID参数的getAll。如果端点不支持该调用,将抛出ApiException()异常。以下是一些访问这些端点的示例

// Get all users
$users = $users->getAll();

// Get a specific user
$users->getById(1234);

// Add a user
$users->add([
    "first_name" => "John",
    "last_name" => "Doe",
    "email"=>"johndoe@example.com",
    "roles"=>[]
  ]);

// Update a user
$users->update( 1234, [
    "first_name" => "John",
    "last_name" => "Doe",
    "email"=>"johndoe@example.com",
    "roles"=>[]
  ]);

// Delete a user
$users->delete( 1234);

有关哪些端点支持哪些端点的更多详细信息,请确保您查阅了Thinkific API文档