Webservice API integrations

Webservice API integrations

by Wendi Daniels -
Number of replies: 19

I am a total novice in terms of api integration. How difficult is it? If I were to do it myself, what is the likelihood that I could mess it up? I don't mind diving into something I have never done so long as the road signs are clear and legible.


Please advise....

Average of ratings: -
In reply to Wendi Daniels

Re: Webservice API integrations

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

What exactly are you trying to integrate Moodle to?

It is not fundamentally difficult to enable web services in Moodle. However, it is a bit fiddly because there are a number of things to set up. This is so you can allow access to the bits you want to be accessible, without opening up the entire site for hackers. Anyway, the good news is that there is a nice page Site administration -> Plugins -> Web services -> Overview which guides you through all the things you need to do.

However, as I said, the Moodle side is just one half. What is going to be at the other end of the integration, and can you get it to talk to Moodle?

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Webservice API integrations

by Wendi Daniels -

I was just given all of the "stuff" by a state board so that I can integrate it into my site so that my site talks to their system. So I think I have everything on their side. I just need it to go on my side.


Thank you, I found that and I will look into it when I can, in about an hour.

In reply to Wendi Daniels

Re: Webservice API integrations

by Wendi Daniels -

Hey Tim, I'm going through the steps...what do I want to declare the function to be? It is an api that will report to a state board that certain people passed the course.

In reply to Wendi Daniels

Re: Webservice API integrations

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This is a key point about web services. They go in a particular direction. One system makes a request (or send a message) to another system.

The Moodle web service system is designed to be a way for Moodle to answer requests (receive messages) from another system.

It sounds like you are in the other scenrario. You are being asked to have Moodle send a message to the state board when something happens in Moodle.

Therefore, you will need to do something else (probably make a small Moodle plugin). I think we might need a few more details about what you are being asked to do, in order to advice you properly.

In reply to Tim Hunt

Re: Webservice API integrations

by Wendi Daniels -

This is the sample string I was given, that they said should make sense to the programmer.


UID|PW|4743|04172013|1800|5337|6443|Joe|Sam|Hunt||11231955|F|0967|04172013|Putnam|4257WPP|B1|H123456781020|FL|||Po box 674||(city)|(state)|(zip code)||(phone number)


I have no idea what the rest of these numbers mean.|

In reply to Wendi Daniels

Re: Webservice API integrations

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I have not idea what most of that means either. There are bits that you might guess were name and address, and 04172013 might be a date if you were an American.

However, they really need to give you some proper documentation for whatever web service it is that they want you to integrate with.

In reply to Tim Hunt

Re: Webservice API integrations

by Wendi Daniels -

Well, one more question...I have a page of code that is to be uploaded on one of the FTP files (I think). Where would webservice code be uploaded to? I see the "webservice" file in FTP, but where do I go from there?


Yeah, the dating system in America is a bit silly, isn't it?   month/day/year???

In reply to Wendi Daniels

Re: Webservice API integrations

by Wendi Daniels -

Tim, when you say "create a plugin", would that plugin go in "functions"?

In reply to Wendi Daniels

Re: Webservice API integrations

by Jez H -

Hi Wendi,

From what you have said I dont think you need to create functions etc.

The string you gave earlier looks like user details, perhaps part of this integration is to create / auto update users? It may help if you explain specifically what this integration does?

What I think you need to do is enable standard web services of which there are many if you scroll down this page:

https://docs.moodle.org/dev/Web_services_Roadmap

That involves creating a user account for the remote application, assigning it permissions and generating a token. The remote application then "logs in" as this "user" To control bits of moodle like creating users, enroling users on courses etc.

For that you would not need to create functions, just use the ones in the list linked above.

However, if the integration goes the other way and you want to get Moodle to send information to the other system you would as Tim said need to write (as in programming) a plugin to detect an event in Moodle and call the web service in the remote application. If this is a commercial product which integrates with Moodle you would normally expect them to provide the plugin to all their customers.


In reply to Jez H

Re: Webservice API integrations

by Wendi Daniels -

Yes, I have the API from the board, and I need to integrate it into moodle. So it sounds like perhaps I have all that I need? I will look over that roadmap.

In reply to Wendi Daniels

Re: Webservice API integrations

by Jez H -

Well if they want you to provide a user / token so their application can access Moodle I think you will have what you need.

If they are asking you to post data from Moodle back into their application then you would need a plugin.

Unless you can divulge more specifically what this integration does its hard to know what you need to do.

In reply to Jez H

Re: Webservice API integrations

by Wendi Daniels -

I have no problem divulging all of it, but not publicly, because I would likely cause havoc if I allow other people to hook up to their site.


Here are the beta instructions they gave me:

To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:  (and then there is coding)


I'm not sure what this instruction means. What does it mean to "create a client to call the service"? In any case, I can do it with this coding, but where do I put it? I can't publicly release the coding. I have a string of code mentioned earlier in this thread, and I don't know where to put that, either.

In reply to Wendi Daniels

Re: Webservice API integrations

by Jez H -

By divulge I did not mean post credentials but explain what it does. For example "auto create users in moodle then enrol them on courses" or "when use passes quiz send grade to remote system".

From what you say in your last comment it sounds like you are trying to control the other application via web services and not Moodle.

In moodle terms "creating a client" would mean creating a plugin in PHP which called this other API and that could involve a lot of effort.

If that is the case I would try and get them to build something on the basis that Moodle is open source (meaning they can write and submit plugins) and popular (lots of companies integrate with Moodle to drive more sales).

In reply to Jez H

Re: Webservice API integrations

by Wendi Daniels -

What the api does is when a specific student passes the final test, the board is notified with all the the student's specific information. If they don't pass the final test, nothing happens.


********************************************************************************************************

"From what you say in your last comment it sounds like you are trying to control the other application via web services and not Moodle."

I don't mean to imply one or the other. I am not sure how to put this together. I have the information, a beta testing site, a test site, and then a final production system. I'm not clear on how to use it, where in the code I insert the shortname for the different fields, and where in ftp I insert the final code. Do you know where I would insert their code in the ftp files?

In reply to Wendi Daniels

Re: Webservice API integrations

by Wendi Daniels -

Do I install my api as a local plugin?

In reply to Wendi Daniels

Re: Webservice API integrations

by Jez H -

The API would reside on the other system you want to send information too, that already exists.

To send the information you would need a plugin to detect the pass grade in Moodle and then send the data over to the other aplication. Does this company provide a Moodle plugin to do this?

If they do you would need to install it in Moodle and configure it.

So the plugin would be installed in Moodle (if they have one) and that plugin would "talk" to the API built into the other application.

If this has been provided by a commercial company they probably have a support desk you could ask for help.

In reply to Jez H

Re: Webservice API integrations

by Wendi Daniels -

They don't have support desk available, they just say "here it is, run with it". That is why I am here, trying to figure it out. I hired someone on Odesk, but he did not get back to me. I could always hire someone else. I was trying to figure out more about this so I can give it to him or any other programmer.


So, I have the info, but I don't know what it is or what to do with it. Where would I install code? What can I tell the programmer? How long would you estimate this would take? We are trying to find a price to agree on, and I do not know, and he hasn't looked it over yet. All insight is appreciated.

In reply to Wendi Daniels

Re: Webservice API integrations

by Jason Ferguson -

If I understand this correctly;

You don't need to integrate an external webservice API on your moodle end.  

IE:  the outside system is not communicating with moodle to retrieve the completion data.

You are passing the completion data to (outside system) API

What seems to be needed is a simple event trigger that checks for the occurrence of a course being flagged as completed then firing off the relevant information to the external system.

Overall; fairly simple and straight forward,  development time is minimal, the only real question is "can moodle provide all the information the third party api is expecting".   

The string provided above is not very helpful if that is an example of the data they are expecting to receive. 

If you can't find a developer, feel free to contact me privately.