使用TinCan API从Learning Locker LRS获取语句

时间:2016-02-29 06:19:10

标签: php tin-can-api lrs learning-locker

我试图通过PHP和TinCanPHP API对存储在Learning Locker中的语句执行查询。通过这个answer,我能够从Learning Locker获取回复。以下是回复的一部分:

TinCan\LRSResponse Object
(
    [success] => 1
    [content] => TinCan\StatementsResult Object
        (
            [statements:protected] => Array
                (
                    [0] => TinCan\Statement Object
                        (
                            [id:protected] => 9ea9e6b6-8278-4545-a02c-c46113f3ba30
                            [stored:protected] => 2016-02-28T12:04:01.670600+00:00
                            [authority:protected] => TinCan\Agent Object
                                (
                                    [objectType:protected] => Agent
                                    [name:protected] => New Client
                                    [mbox:protected] => mailto:hello@learninglocker.net
                                    [mbox_sha1sum:protected] => 
                                    [openid:protected] => 
                                    [account:protected] => 
                                )

                            [version:protected] => 1.0.0
                            [attachments:protected] => Array
                                (
                                )

                            [actor:protected] => TinCan\Agent Object
                                (
                                    [objectType:protected] => Agent
                                    [name:protected] => Subhayan Roy
                                    [mbox:protected] => mailto:subhayanroy5@gmail.com
                                    [mbox_sha1sum:protected] => 
                                    [openid:protected] => 
                                    [account:protected] => 
                                )

                            [verb:protected] => TinCan\Verb Object
                                (
                                    [id:protected] => http://activitystrea.ms/schema/1.0/search
                                    [display:protected] => TinCan\LanguageMap Object
                                        (
                                            [_map:protected] => Array
                                                (
                                                    [en-US] => Searched
                                                )

                                        )

                                )

返回的语句列表具有权限protected,因此我无法访问它们。我如何访问这些陈述?我在这里缺少什么?

1 个答案:

答案 0 :(得分:3)

您需要使用库中内置的方法。在这种情况下,你想要的是getStatements。

(int16_t)

请参阅此处的文档:http://rusticisoftware.github.io/TinCanPHP/doc/api/latest/classes/TinCan.StatementsResult.html#method_getStatements

回答接下来要问的问题(为什么我没有在结果中返回所有语句?),看一下Statement Result getMore方法,该方法为您提供了更多的URL和远程LRS moreStatements方法,接受更多URL并获取下一批语句。请参阅此代码示例:https://github.com/garemoko/TinBadgesPHP/blob/b8789042f4af23f0f7927596e8e7f2a06655db72/TinBadges/RemoteLRS.php#L84-L96