Aquesta pàgina forma part de la documentació de Moodle en català, tot i que no ha estat traduïda encara. Podeu contribuir obertament a les tasques de traducció. Podeu consultar la Guia d'edició de la documentació i també participar ens els debats del fòrum de traductors de la documentació a moodle.org

Using web services: diferència entre les revisions

De MoodleDocs
Salta a:navegació, cerca
Cap resum de modificació
Línia 1: Línia 1:
{{Moodle_2.0}}This document explains how an administrator set up a web service for ordinary users.
{{Moodle_2.0}}This document explains how an administrator set up a web service for ordinary users.
==Introduction==
=Introduction=
A user goes on his security keys page. He gets a security key (also called token). He enters the key on the external application accessing to Moodle. At any time, a user can reset the key if he suspects that it has been stolen. The key is complex, long and difficult to generate. This is the recommended authentication method for web service. This document explains how a Moodle administrator can set it up.
A user goes on his security keys page. He gets a security key (also called token). He enters the key on the external application accessing to Moodle. At any time, a user can reset the key if he suspects that it has been stolen. The key is complex, long and difficult to generate. This is the recommended authentication method for web service. This document explains how a Moodle administrator can set it up.


== Enable the web service in Moodle ==
= Enable the web service in Moodle =
   Settings block > Site Administration > Advanced features<br/>
   Settings block > Site Administration > Advanced features<br/>
   Check '''Enable web services''' option and '''Save Changes'''
   Check '''Enable web services''' option and '''Save Changes'''
[[Image:enable_ws_option.png|800px]]   
[[Image:enable_ws_option.png|800px]]   


== Enable a protocol ==
= Enable a protocol =
   Settings block > Site Administration > Plugins > Web services > Manage protocols<br/>
   Settings block > Site Administration > Plugins > Web services > Manage protocols<br/>
   Enable the desired protocol (SOAP, REST, XMLRPC, AMF, ...)
   Enable the desired protocol (SOAP, REST, XMLRPC, AMF, ...)
[[Image:ws_manageprotocal_settings.png|800px]]
[[Image:ws_manageprotocal_settings.png|800px]]


== Enable capabilities to users==
= Enable capabilities to users=
=== for create token ===
== for create token ==
you need to set "moodle/webservice:createtoken" capability to the users
you need to set "moodle/webservice:createtoken" capability to the users
=== for protocols ===
== for protocols ==
you need to set the activated protocol (webservice/rest:use, webservice/soap:use,...) capability to the users
you need to set the activated protocol (webservice/rest:use, webservice/soap:use,...) capability to the users


== Create a service with funtions ==
= Create a service with funtions =
   Settings block > Site Administration > Plugins > Web services > External Services
   Settings block > Site Administration > Plugins > Web services > External Services
   Click on '''Add''' new custom service
   Click on '''Add''' new custom service
Línia 25: Línia 25:




===Add new custom service page===
==Add new custom service page==
A service is a group of web service functions. You need to create first the service then add the function. When you create the service do not check "Authenticated users", we want all users (only the one with "moodle/webservice:createtoken" capability) to be able to use the web service. If you want you can select a required capability. Any user access a web service will be checked against it. It is just an additional and optional security layer for your own usage.
A service is a group of web service functions. You need to create first the service then add the function. When you create the service do not check "Authenticated users", we want all users (only the one with "moodle/webservice:createtoken" capability) to be able to use the web service. If you want you can select a required capability. Any user access a web service will be checked against it. It is just an additional and optional security layer for your own usage.
   Enter a name, check enable
   Enter a name, check enable
Línia 31: Línia 31:
[[Image:add_webservice.png|800px]]
[[Image:add_webservice.png|800px]]


===Add a function to the service ===
==Add a function to the service ==
   Settings block > Site Administration > Plugins > Web services > External Services<br/>
   Settings block > Site Administration > Plugins > Web services > External Services<br/>
   Click on the Functions link for the newly created service
   Click on the Functions link for the newly created service
Línia 44: Línia 44:




== Users visit web service page to get auto token==
= Users visit web service page to get auto token=
the users will go on their profil block and access their security keys. The first time a user access this page, his key is created.
the users will go on their profil block and access their security keys. The first time a user access this page, his key is created.


[[Category:Web Services]]
[[Category:Web Services]]

Revisió del 06:27, 18 gen 2010

Plantilla:Moodle 2.0This document explains how an administrator set up a web service for ordinary users.

Introduction

A user goes on his security keys page. He gets a security key (also called token). He enters the key on the external application accessing to Moodle. At any time, a user can reset the key if he suspects that it has been stolen. The key is complex, long and difficult to generate. This is the recommended authentication method for web service. This document explains how a Moodle administrator can set it up.

Enable the web service in Moodle

  Settings block > Site Administration > Advanced features
Check Enable web services option and Save Changes

Enable a protocol

  Settings block > Site Administration > Plugins > Web services > Manage protocols
Enable the desired protocol (SOAP, REST, XMLRPC, AMF, ...)

Enable capabilities to users

for create token

you need to set "moodle/webservice:createtoken" capability to the users

for protocols

you need to set the activated protocol (webservice/rest:use, webservice/soap:use,...) capability to the users

Create a service with funtions

  Settings block > Site Administration > Plugins > Web services > External Services
  Click on Add new custom service


Add new custom service page

A service is a group of web service functions. You need to create first the service then add the function. When you create the service do not check "Authenticated users", we want all users (only the one with "moodle/webservice:createtoken" capability) to be able to use the web service. If you want you can select a required capability. Any user access a web service will be checked against it. It is just an additional and optional security layer for your own usage.

  Enter a name, check enable
  Click on Save changes

Add a function to the service

  Settings block > Site Administration > Plugins > Web services > External Services
Click on the Functions link for the newly created service


Service functions page

  Select Add function operation, then select a function and Save changes


Users visit web service page to get auto token

the users will go on their profil block and access their security keys. The first time a user access this page, his key is created.