承接 smtech/canvaspest 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

smtech/canvaspest

最新稳定版本:v1.1.9

Composer 安装命令:

composer require smtech/canvaspest

包简介

An extension of Pest to make RESTful queries to the Instructure Canvas API

README 文档

README

Latest Version Scrutinizer Code Quality Code Coverage Build Status

Object-oriented access to the Canvas API using PHP.

Install

In your composer.json, include:

"require": {
	"smtech/canvaspest": "1.*"
}

Use

CanvasPest

Create a new CanvasPest to make RESTful queries to the Canvas API:

// construct with the API URL and an API access token
$api = new CanvasPest('https://canvas.instructure.com/api/v1', 'df2bcbad95f606d6e80093f8e40c4e5ca171d8c5e4f2138e1d58273e33b262ef')

Make a RESTful query to the API:

// GET, PUT, POST, DELETE are all supported
$obj = $api->get('users/self/profile');

The response from a query is either a CanvasObject or a CanvasArray (of CanvasObjects, natch), depending on whether you requested a specific object or a list of objects (even if the list turns out to be a single object).

CanvasObjects

CanvasObject fields can be accessed either object-style or array style:

$obj = $api->get('courses/123');
echo $obj['sis_course_id']; // array-style
echo $obj->title; // object-style

CanvasArrays

CanvasArrays can be iterated conveniently using the foreach control structure.

$arr = $api->get('/accounts/1/users');
foreach($arr as $obj) {
	echo $obj->name;
}

One could also access arbitrary elements of the CanvasArray:

$arr = $api->get('accounts/1/courses');
echo $arr[1337]->title;

Note that both CanvasObjects and CanvasArrays are immutable objects -- that is, they are treated as read-only. In fact, if you attempt to alter a CanvasObject or a CanvasArray, exceptions will be thrown.

Full API documentation is available in the repository.

统计信息

  • 总下载量: 4.8k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 5
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2015-05-28