flat/api

Flat REST API 的 PHP 客户端

0.8.2 2018-04-26 13:16 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:09:38 UTC


README

Build Status Packagist

Flat API 允许您轻松扩展 Flat 平台 的功能,包括以下广泛用例:

  • 使用 MusicXML 或 MIDI 文件创建和导入新的音乐乐谱
  • 浏览、更新、复制、导出用户的乐谱(例如 MP3、WAV 或 MIDI 格式)
  • 使用 Flat for Education 管理教育资源:创建和更新组织账户、班级、名单和作业。

您可以在以下 URL 找到 API 参考,包括代码示例和我们的 OpenAPI 规范:https://flat.io/developers/api/reference

要请求一些 API 凭据,请访问 https://flat.io/developers

此 Python 包由 Swagger Codegen 项目自动生成。

要求

PHP 5.6.0 及以上版本

安装与使用

Composer

要使用 Composer 安装绑定,请将以下内容添加到 composer.json 文件中:

{
    "name": "Example Application",
    "description": "This is an example using the Flat API",
    "require": {
        "flat/api": "dev-master"
    }
}

然后运行 composer install

手动安装

下载文件并包含 autoload.php

require_once('/path/to/./vendor/autoload.php');

测试

要运行单元测试

composer install
./vendor/bin/phpunit

入门

请按照安装过程进行操作,然后运行以下命令:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = Flat\APIClient\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');

$apiInstance = new Flat\APIClient\Api\AccountApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->getAuthenticatedUser();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AccountApi->getAuthenticatedUser: ', $e->getMessage(), PHP_EOL;
}

?>

API 端点文档

所有 URI 都相对于 https://api.flat.io/v2

模型文档

授权文档

OAuth2

  • 类型: OAuth
  • 流程: accessCode
  • 授权URL: https://flat.io/auth/oauth
  • 作用域:
  • account.public_profile: 提供对基本个人公共资料的访问权限。使用此作用域,教育资料可能被匿名化,您可以请求education_profile作用域以访问基本教育账户资料。
  • account.education_profile: 提供对基本个人教育资料和公共组织信息的访问权限。
  • scores.readonly: 允许只读访问所有用户的分数。您不需要此作用域来读取公共分数。
  • scores.social: 允许发布评论和喜欢分数。
  • scores: 完全权限的作用域,用于访问所有用户的分数。
  • collections.readonly: 允许只读访问用户的收藏。
  • collections.add_scores: 允许向用户的收藏中添加分数。
  • collections: 完全权限的作用域,用于访问所有用户的收藏。
  • edu.classes: 完全权限的作用域,用于管理班级。
  • edu.classes.readonly: 只读访问班级。
  • edu.assignments: 读写访问作业和提交。
  • edu.assignments.readonly: 只读访问作业和提交。
  • edu.admin: 完全权限的作用域,用于管理组织的所有管理权限。
  • edu.admin.lti: 访问和管理组织的LTI凭证。
  • edu.admin.lti.readonly: 只读访问组织的LTI凭证。
  • edu.admin.users: 访问和管理组织的用户和邀请。
  • edu.admin.users.readonly: 只读访问组织的用户和邀请。

作者

developers@flat.io