Quantcast
Channel: Web services
Viewing all 2269 articles
Browse latest View live

Using enrol_manual_enrol_users via XML-RPC.NET

$
0
0
by Mike Z.  

Hello all,

I need your help with consuming the webservice:  enrol_manual_enrol_users

My client app is in ASP.NET, and I am using the XML-RPC.NET library to make XML-RPC calls to Moodle.  

I should note that I am able to successfully call the web service "core_user_get_users_by_id".  However that is a simple case. It takes an Int array as the parameter and returns an object array containing hashtables, one per user record, and with each key-value pair representing a field from the user table.

However for enrol_manual_enrol_users, I can't figure out how I should code the Method call or handle the return object.  Indeed, from the Moodle documentation, there is nothing listed under the "Response" heading for this method.

Here is what I currently have, but this is giving me a rather useless "[404] Unknown error" as the response from Moodle.  I expect the problem is because I don't really understand how to use the Struct in the method call, or how to obtain the result from Moodle's response.

 

Here is the interface definition

public interface IMoodle : IXmlRpcProxy {

[XmlRpcMethod("enrol_manual_enrol_users")]
object[] Enrol_Manual_Enrol_Users(Moodle_Enrolment[] input);      //Not sure if it should be delcared as object[] or not, as there is no Response described in the Moodle docs.

}

 

And the Struct that should represent the input parameter for the webservice

    public struct Moodle_Enrolment
    {
        public int roleid;
        public int userid;
        public int courseid;
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int timestart;
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int timeend;
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int suspend;
    }

 

And here is the code that instantiates the struct, and calls the WebMethod.

           Moodle_Enrolment me = new Moodle_Enrolment();

            me.courseid = 2  //this defiinately exists in the Moodle database
            me.userid = 7;    //this defiinately exists in the Moodle database
            me.roleid = 1;   
            
            Moodle_Enrolment[] meArray = {me};       //Put the enrolment details into an array.

            try
            {
                object[] a = moodleServer.Enrol_Manual_Enrol_Users(meArray);    //not sure what the response datatype is
            }
            catch  (Exception ex)
            {

                   //Error handling code goes here

            }

When this code runs, an exception occurs on the call to Moodle, and the exception message is:

Server returned a fault exception: [404] Unknown error

 

So - can you offer any suggestions on how to fix this?  I am sure I am doing something wrong here - but the documentation on the webservice enrol_manual_enrol_users is really not helping me much.    

Unfortunately this web service is not available in the Moodle test client.  Any suggestions on how I can find out about this 404 Unknown Error?

 

Thanks for your help all,

Mike

 

 


Adding more functions to the service "My service" (local template)

$
0
0
by Oliver Obermayr.  

Hi there, recently I've started to use local_wstemplate (via rest protocol), which is called 'My service' and has only local_wstemplate_hello_world function by default. I want to add more functions to this service, namely core_course_get_contents and a function that is responsible for getting calendar events. As a tutorial I followed this guides: Adding_a_web_service_to_a_plugin and External_functions_API. But I couldn't get the way how to add above functions to the 'My service' plugin located in moodle/local/wstemplate/.

Do I need to extend wstemplate/db/services.php and wstemplate/externallib.php files respectively or create another php files? By the way there is no information and required arguments about getting calendar events in the documentation External functions API.

Any help or advice would be great.

Re: Get a user token https

$
0
0
por Oliver Obermayr.  

You need enable https:// in your php.ini file:

  • extension=php_openssl.dll (uncomment it)
  • allow_url_include = On (change to on)

then try again with cURL using following parameters:

  • curl_setopt($ch, CURLOPT_SSLCERT, "example.p12");
  • curl_setopt($ch, CURLOPT_SSLCERTTYPE, "P12");
  • curl_setopt($ch, CURLOPT_SSLKEYPASSWD, "password here");

"Add Functions" link is missing

$
0
0
by Chris C.  

I have a plugin which works well on several Moodle sites.  It has custom functions, and uses core functions such as core_user_create_users.  To do this, I login as administrator, and go to Site Administration > Plugins > Web services > External services > Functions, and there is an "Add Functions" link button which allows me to add functions.  I'm trying to set it up on another site, and this site does not have the "Add Functions" link button.  First time I've seen this.  Using $release = '2.3.3 (Build: 20121112)'

Have any of you seen this before?  Any ideas why "Add Functions" might be missing, and how I might restore it?

Is this a bug? Add function in Web service

$
0
0
by Jeff Young.  

Hi there, 

When I tried Add function in web service of Moodle 2.4, I got this error message as " Coding error detected, it must be fixed by a programmer: Can not find file with external function implementation".

Is this a bug?

 

Thanks,

Jeff 

Re: Login webservice

$
0
0
por Bayu Wicaksono.  

Hai Jerome, i have a problem here,, hope you can help
by using the web-service i got the token,, so that i can access more services,, but in some service that return URL,,

why does it need to re-login.

is it possible to make it not to re-login just by getting the token,, thanks

-bayu

 

Re: Is this a bug? Add function in Web service

$
0
0
by Paul Charsley.  

Hi Jeff,

This can happen when a web service function defined in your Moodle database does not exist in your Moodle code. It may happen if you switch to an older source code branch but are still using a newer database. It is unlikely to be a bug.

When I encounter this error I usually check the functions listed in the table mdl_external_functions to verify that my Moodle installation contains the corresponding code.

Paul

Accessing (export) calendar via web-sevices

$
0
0
by Oliver Obermayr.  

I'm wondering about exporting of moodle Calendar via web services or by calling some link. For the experiment I've tried to call the calendar via link provided by moodle (Get calendar URL) and it gived me the following link:

Calendar URL: http://localhost/moodle/calendar/export_execute.php?userid=2&authtoken=b1b4b7995fff29739050ad97abd14485b1284e03&preset_what=courses&preset_time=monthnow

this link is workable until userid=2 and authtoken=b1b4b7995fff29739050ad97abd14485b1284e03

Question: Is there some way to use web-services user token to export the calendar instead of authtoken by calling this link?

If someone have other approach, he/she could share here smile


which API to connect two different application

$
0
0
by prashant galagali.  

i am using two different s/w application one is CMIS(.Net) another one is LMS(Moodle)

suppose user data is entered in CMIS (GUI ), API sends the information to LMS and logins would be created automatically means without moodle login (lms)  login throgh CMIS then automatically data saved in LMS(moodle site)

so which API i used to achieve this or any other procdure is there suggest me

Moodle/PayPal communication issue

$
0
0
by Erik Rosen.  

Not sure where else to post this (I tried general), so if there is a more appropriate forum, please let me know and I'll be happy to move this.

We use Moodle for our non-profit, offering online courses and certifications for our students.  When someone is NOT logged into Moodle and makes a purchase or donation using the PayPal "Buy Now" button, we receive a heads-up email from PayPal which includes their physical address.

However, when a student is logged in and makes a purchase the same way, we get the same heads-up email but WITHOUT their physical address (which they need to input to make the purchase).

Is there a setting in Moodle that might address this, or does anyone have any experience with it?

Thank you!

Re: Is this a bug? Add function in Web service

$
0
0
by Jeff Young.  

Hi Paul,

thanks for your help.

I checked the table as advised and found that there is no coresponding code there. I will look into the web service installation later.

Cheers,

Jeff

webservice/upload.php returning zero instead of actual itemid

$
0
0
por Martin Mastny.  

Hello everyone,

I'm using this "webservice" to upload files in moodle, which is fine, but when the json string is retrieved, it has itemid set to 0 (zero).

But whe I log in into moodle later, this uploaded file has a different itemid. I suppose that itemid is the huge number in the following link, which I can use to adress file

I'm on moodle 2.3

draftfile.php/104/user/draft/419799805/test6/image.jpg

my question is, how can I get the link to uploaded file, if the itemid is always 0???

Thanks M

Re: REST Service Create User C# Example [Moodle 2.3.1]

$
0
0
por Soh Chee Wei.  

Is there any example for use with Visual Studio 2008?

Re: REST Service Create User C# Example [Moodle 2.3.1]

Re: webservice integration

$
0
0
by Vijoi A.M.  

Hi all,

          I am creating an e-learning website.I want to create a web service to get contents of my moodle. Could anybody tell me how to do that?

 

Thanks in advance.


Re: webservice integration

$
0
0
by Vijoi A.M.  

Hi All,

I am creating an e-learning website.I want to create a web service to get contents of my moodle. Could anybody tell me how to do that? Should i create a token to retrive datas from moodle?.Plz reply ASAP. Its urgent.

 

Thanks in advance.

SSO Login from another system using OkTech

$
0
0
by Raymond Cosgrave.  

My Moodle Integration Steps using OKTech and Moodle Web Services:
Create/Grab User (works)
Add User to Course (works)
 Login User via Web Service (works to an extent, described below)
Send user to course view page, logged in (works to an extent but can fail due to step above)

I am using jQuery to send a $.get() to my moodle installation (I also cannot grab the loginReturn Object because the get is sent as OPTIONS) to login the user like below (feel free to use the below URL to test, this is a development site):


http://ec2-50-16-18-214.compute-1.amazonaws.com/moodle/wspp/service_pp2.php?username=jdunbar@peachnewmedia.com&password=XeGRL44x&wsfunction=login&wsformatout=dump

This works fine for the first login however subsequent logins when:


The user hits the logout button on moodle


The user switches browsers and tries to view the course again


Makes all subsequent logins fail and send the user to the login page (the user would NOT know their password to Moodle since we are sending them from our application to Moodle "seamlessly").


I could be approaching this all wrong in terms of developing a SSO but any tips you can give me regarding the above will be greatly appreciated!

Re: webservice/upload.php returning zero instead of actual itemid

$
0
0
by Martin Mastny.  

Ok, I found a solution myself. Here it is.

Itemid = 0 is a basic itemid in database and file gets really uploaded with it. When you need uploaded file, system copies a database entry a creates a link with unique itemid and then you can use this file with created itemid. This is not a good idea, because whole structure of private files in database gets copied everytime you refresh private files page. Seems like a good entry foint for overfilling the database and potential attack to me. Of course I could be wrong.

Cheersbig grin

Martin

Moodle Web Service functions : Can I do this?

$
0
0
by Batiste Roger.  

Hi,
I am a young developper and I currently work on a project that involves a LMS and an external system. I would like to have them work independently (other languages, other servers...) but the system I will be coding will need to extract data from the LMS about the user's scores / participation to the courses.

I was wondering if it is possible to extract these details thanks to a web service (I would like to avoid taking the data directly in the DB, it would be awful). Are there functions that I can use to export the user's results?

Thank you in advance for your help. Don't hesitate to answer with links / documents that I can read, I am lost in all the versions / documentation!

Re: Moodle Web Service functions : Can I do this?

Viewing all 2269 articles
Browse latest View live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>