简体   繁体   English

基于REST的Moodle Function API文档

[英]Moodle Function API doc over REST

I am trying to develop a Moodle Android app. 我正在尝试开发Moodle Android应用。 I am using MoodleREST source code for my reference.Is there any other documentation on Moodle site which documents moodle core webservice functions with their required params. 我正在使用MoodleREST源代码作为参考.Moodle网站上是否有其他文档可以记录核心Web服务功能及其所需参数。

I have found list of functions here http://docs.moodle.org/dev/Web_services_Roadmap but could not get proper documentation on how to call these functions with required params from mobile client using REST. 我在http://docs.moodle.org/dev/Web_services_Roadmap中找到了功能列表,但无法获得有关如何使用REST从移动客户端使用必需的参数调用这些功能的适当文档。

I am new to moodle and still learning it, so my question can be a little naive so please bear with it :) 我是新手,仍然学习它,所以我的问题可能有点天真,所以请忍受:)

This could be helpful http://docs.moodle.org/dev/Creating_a_web_service_client 这可能会有所帮助http://docs.moodle.org/dev/Creating_a_web_service_client

And if you have some administrator access to Moodle, go to 如果您拥有Moodle的管理员访问权限,请转到

yourmoodle/admin/webservice/documentation.php , or yourmoodle / admin / webservice / documentation.php,或

Administration > Plugins > Web services > API Documentation . 管理>插件> Web服务> API文档

There is API with documentation. 有带有文档的API。 (Dont know if there is better way though :/) (不知道是否有更好的方法:/)

D. D.

AIUI you need admin to access the most comprehensive web service API, as described by @Dolfa. AIUI,您需要管理员才能访问最全面的Web服务API,如@Dolfa所述。 You'll need these docs and/or the source if you're developing against their REST API. 如果要针对他们的REST API进行开发,则需要这些文档和/或源代码。 The API docs are generated from the source, presumably so they accurately reflect the API in the installed version. API文档是从源代码生成的,因此大概可以准确地反映已安装版本中的API。

You could: 你可以:

  • Browse the code on github 浏览github上的代码
  • Clone the version you intend to program against so you can browse the code locally 克隆要编程的版本,以便您可以在本地浏览代码
  • Install it and give yourself admin so you can browse the API docs. 安装它并让您自己成为admin,以便您可以浏览API文档。

If you don't want to go through the hassle of setting up a local Moodle instance, you may be able to figure out a way to run the php that generates the docs . 如果您不想麻烦地设置本地Moodle实例,则可以找到一种方法来运行生成文档的php

Once you have a rough idea of an API call, you can often find out the details by looking at responses to command-line requests eg 大致了解API调用后,您通常可以通过查看对命令行请求的响应来找到详细信息,例如

curl 'https://your.domain/webservice/rest/server.phpmoodlewsrestformat=json' --data 'wsfunction=core_enrol_get_users_courses&wstoken=[your_ws_token]' --compressed | python -m "json.tool"

gives the response 给出回应

{
    "debuginfo": "Missing required key in single structure: userid",
    "errorcode": "invalidparameter",
    "exception": "invalid_parameter_exception",
    "message": "Invalid parameter value detected"
}

indicating that the function requires a userid=[userid] argument. 指示函数需要一个userid=[userid]参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM