Web services: Difference between revisions
From MoodleDocs
Rich Trott (talk | contribs) m (→How it works) |
|||
(44 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
=== How it works === | |||
This example will give you an idea of how our web services infrastructure works. | |||
#The client sends a username and password to the web service login script. | |||
#The script returns a token for that user account. | |||
#The client calls a particular web service function on a protocol server including the token . | |||
#The protocol server uses the token to check that the user can call the function. | |||
#The protocol server calls the matching external function, located under the \component\external namespace (previously in a externallib.php file inside the relevant module). | |||
== How it works == | |||
This | |||
#The client sends a username and password to the web service | |||
#The | |||
#The client calls a particular web service function including the | |||
#The protocol server uses the token to check that the | |||
#The protocol server | |||
#The external function checks that the current user has_capability to do this operation. | #The external function checks that the current user has_capability to do this operation. | ||
#The external function calls the matching Moodle core function (in lib.php usually). | #The external function calls the matching Moodle core function (in lib.php usually). | ||
Line 22: | Line 12: | ||
#The protocol server returns the result to the client. | #The protocol server returns the result to the client. | ||
== | == Developer documentation== | ||
The full API can be found on any Moodle sites under ''' Administration block > Plugins > Web services > API Documentation'''. | |||
'''Note:''' Additional services are available for uploading and downloading files which are not in the API Documentation - they are accessed in a different way. See [[Web services files handling]] | |||
* [[How to contribute a web service function to core]] | |||
* [[Adding a web service to a plugin| Adding a web service to your plugin]] | |||
* Code example: [https://gist.github.com/timhunt/51987ad386faca61fe013904c242e9b4 Adding a web service, using APIs] by (Tim Hunt) | |||
* [[Creating a web service client | Implement a web service client]] | |||
* [[Web services files handling]] | |||
* [[Web_services_Roadmap | Web service Listing & Roadmap]] | |||
== | == Specification and brainstorming == | ||
* [[External services security | External services security]] | |||
* [[External services description | External services description]] | |||
== | == See also == | ||
* [[Web_service_API_functions|Web service API functions]] | |||
* [[:en:Web_services_FAQ|Web services FAQ]] | |||
* [[ | * [[:en:How_to_create_and_enable_a_web_service|How to create and enable a web service]] | ||
* [[ | * [[:en:Enable mobile web services|How to enable the mobile web service]] | ||
* [[:en:Web_services|Web services user documentation]] | |||
* [http://www.slideshare.net/juanleyva/mastering-moodle-web-services-development Mastering Moodle Web Services development] - Last session of the Hackfest in the MoodleMoot UK 2016 | |||
[[Category: | [[Category:Web_Services]] |
Revision as of 17:47, 30 October 2020
How it works
This example will give you an idea of how our web services infrastructure works.
- The client sends a username and password to the web service login script.
- The script returns a token for that user account.
- The client calls a particular web service function on a protocol server including the token .
- The protocol server uses the token to check that the user can call the function.
- The protocol server calls the matching external function, located under the \component\external namespace (previously in a externallib.php file inside the relevant module).
- The external function checks that the current user has_capability to do this operation.
- The external function calls the matching Moodle core function (in lib.php usually).
- The core function can return a result to the external function.
- The external function will return a result to the protocol server.
- The protocol server returns the result to the client.
Developer documentation
The full API can be found on any Moodle sites under Administration block > Plugins > Web services > API Documentation.
Note: Additional services are available for uploading and downloading files which are not in the API Documentation - they are accessed in a different way. See Web services files handling
- How to contribute a web service function to core
- Adding a web service to your plugin
- Code example: Adding a web service, using APIs by (Tim Hunt)
- Implement a web service client
- Web services files handling
- Web service Listing & Roadmap
Specification and brainstorming
See also
- Web service API functions
- Web services FAQ
- How to create and enable a web service
- How to enable the mobile web service
- Web services user documentation
- Mastering Moodle Web Services development - Last session of the Hackfest in the MoodleMoot UK 2016