brunogoossens / easy-lti
PHP的LTI 1.1提供商库。
dev-master
2019-08-20 15:07 UTC
This package is auto-updated.
Last update: 2024-09-21 02:33:00 UTC
README
这是一个PHP库,用于将您的PHP应用程序连接到支持结果和深度链接的LTI消费者平台。
安装库
@TODO add this library to packagist.org so an easy composer install and autoload is possible.
如何使用
验证LTI请求
use BrunoGoossens\LTI\LTIProvider; $lti = new LTIProvider('key', 'secret'); $lti->validateRequest(); // throws an exception if the LTI launch is invalid.
OAuth nonce参数未验证。要验证此参数,您应该添加某种数据库。
在验证LTI启动请求之后,您可以确信$_REQUEST值是安全的。
读取分数
$lti->readScore($outcome_service_url, $result_sourcedid);
写入分数
$lti->postScore($outcome_service_url, $result_sourcedid, 0.7); // score is a value between 0 and 1.
深度链接(内容项消息)
将内容项插入工具消费者。
$contentItems = array( array( '@type' => 'LtiLinkItem', 'mediaType' => 'application/vnd.ims.lti.v1.ltilink', 'title' => 'dummy title', 'icon' => array( '@id' => 'https://example.com/icon.jpeg', 'width' => 32, 'height' => 32 ) ) ); $lti->returnContentItems($url, $contentItems);
此操作将提交一个自动生成的表单,并将其返回给工具消费者。