Web service and custom plugins

Web service and custom plugins

by Rene P -
Number of replies: 0

Hello everybody.

I'm trying to use Web Services, but all of them need userids from Moodle database to identify user and my $_POST doesn't know the Moodle user id-s.

Unique e-mail is used for mapping users between sites. So I have to create plugin into Moodle, which gets $_POST data (with e-mails) from Web Services requester. Then use Web Services functions with user id-s gotten from database with $_POST e-mails. 

So the idealy it would work like:

myrequestersite.com -> $_POST -> mymoodle.com/myplugin.php -> mymoodle.com Web Services 

So when I include locallib.php and whichever protocol I select (REST, SOAP)  - I can't see a way to set parameters (token, username, password).  Even if I could do that, parse_request() inside of run(), changes them back to null, because it only checks if combination of $_GET and $_POST needed variable is set and doesn't check if object variable is set already. So basically only scheme I can see working is:

myrequestersite.com -> $_POST -> mymoodle.com/myplugin.php -> $_POST (By using Zend_Http_Client) -> mymoodle.com Web Services 

Is there a way how to remove 2nd $_POST from this scheme by keeping underlined scheme part, myrequestersite.com tables not being altered and myrequestersite.com not querying Moodle database directly? Also everything inside folder webservice/* are supposed to be left untouched!

I could put all logic in our plugin to use Moodle inner functions, but then comes a risk that they're gonna be changed and that plugin needs to updated.

Sorry for my English and for long post. 

Average of ratings: -