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

List all users or verify user existance by username

$
0
0
by Pedro Laginha.  

Hi,

Using SOAP web service, I want to list all users or, if it is not possible, verify the user existence by username in moodle. Anyone knows how to do it?

Thank's in advance.

Pedro L.


"core_course_get_courses" for Mobile App based on PhoneGap

$
0
0
by Oliver Obermayr.  

Hi to everyone,

I'm implementing an e-leatning app for mobile devices based on PhoneGap, learning materials I'm going to get from moodle system via xml-rpc, where all needed materials (topics, pics, videos) are already located.

Moodle forum has a some tutorials and examples regarding getting courses (core_course_get_courses) or content (core_course_get_contents) from external sources, but I could not decide what I need to do for the start. Could someone please advise me with some path or example next steps? 

p.s. Web services and xml-rpc protocol already enabled from the settings.

Thanks in advance.

Re: "core_course_get_courses" for Mobile App based on PhoneGap

Re: To get all course topics and forums.

$
0
0
by Bayu Wicaksono.  

Hai,, Please,,
i also need answer for this problem,,

any body can help. thankz

Re: "core_course_get_courses" for Mobile App based on PhoneGap

$
0
0
by Oliver Obermayr.  

Hi Roc,

Thanks for your advice. I've tried this: http://docs.moodle.org/dev/Creating_a_web_service_client and after some experience got a set of information in form of xml. So by this link:

https://<mydomain>/moodle/webservice/xmlrpc/server.php?wstoken=<mytoken>&wsfunction=core_course_get_contents&courseid=<id course>

I have now datas like article(topics) names, description, id etc. Everything is good except content itself, I mean those texts of articles which I created aren't there. As I said before, I have one course and inside of this course I created (in form html) a set of articles(topics) and uploaded some images also. I want to show all these articles in a display of mobile device, how todo this?

Thanks in advance

Re: "core_course_get_courses" for Mobile App based on PhoneGap

$
0
0
by roc mehra.  

From the response there will be a fileurl

http://<yourmoodlesite>/webservice/pluginfile.php/14598/mod_resource/content/7/HLR%20ppt.htm?forcedownload=1

You can download the file with token like this

http://<yourmoodlesite>/webservice/pluginfile.php/14598/mod_resource/content/7/HLR%20ppt.htm?forcedownload=1&token=<yourtoken>

and you can display after downloading the content.

If any another solution you will find please share it with me.

Thanks

Re: How to use core_course_get_courses?

$
0
0
by Joshua Johnston.  

Hi Nico,

I am new to moodle and experimenting with the web services api from a rest standpoint. When I try to call core_course_get_courses I get an access control exception and when I step through with a debugger it looks like this service isn't activated (or at least not in the list of services that are active).

 

What did you have to do to enable this service and were you able to solve your issue?

Re: How to use core_course_get_courses?

$
0
0
by roc mehra.  

Hi All,

How i can get some information from external application using web service in moodle.


Re: "core_course_get_courses" for Mobile App based on PhoneGap

$
0
0
by Oliver Obermayr.  

Maybe I was not clear last time... regarding course articles (topics), I was created them (not uploaded html files) via moodle system, Add activities and resources -> RESOURCES -> Page expecting that later I can directly access to them via mobile... From your explanation I got that first I need upload the course materials (articles and topics) in form of files (in html for instance) and then download them, and also in your mentioned url you show hier some roots like http://<mymoodledomain>/..../14598/...../content/7/.... are you shure that in each installed moodle system all materials in 14598/ root for instance?

Web service test client problem

$
0
0
by Emilio de la Torre.  

Hello there,

I have a moodle 2.4 running with a PostgreSQL DB, both in localhost. when i try to run the test client, it returns the URL and nothing more, and doesnt write any changes in the DB... I tried this before with MySQL and Moodle 2.1 and worked. Permissions are all granted, protocols are enabled too... Any ideas what might be the problem?

Thank you in advance!

web service error when passing wstoken and wsfunction in http

$
0
0
by Paul Nolan.  

Hi,

I have only a gentleman's knowledge of Moodle and am trying to try out basic web service functionality.

I am using Moodle 2.4 and think I have set up all permissions in plugins for web services correctly.

When I point my browser to the following url:

http://<my-moodle-site>/webservice/xmlrpc/server.php?wstoken=<token>&wsfunction=core_course_get_courses

I get an error:

faultCode630faultStringUnable to read request

Any help would be greatly appreciated.

Re: web service error when passing wstoken and wsfunction in http

$
0
0
by Joshua Johnston.  

Hi Paul,

I'm not familiar with the XML-RPC implementation in Moodle but usually you cannot make a browser request to an XML-RPC server because it expects the request body to contain XML with the name of the remote function to call.

 

For testing purposes, enable the rest protocol and then try with the url:

http://<my-moodle-site>/webservice/rest/server.php?wstoken=<token>&wsfunction=core_course_get_courses

 

Note: The REST protocol isn't real REST, it is a roll-your-own type protocol with a single endpoint that switches method based off query string parameters

Re: web service error when passing wstoken and wsfunction in http

$
0
0
by Paul Nolan.  

Hi Joshua,

This was VERY useful. It worked immediately based on your suggestions. I mistakengly thought the XMLRPC would automatically reyurn XML as did the suggested REST

This was my first time to use the forum and I am very encouraged.

very many thanks,

Paul

How to retrieve a users name, course, e-mail?

$
0
0
by Huntington Mark.  

Will I need to refer to the database for this? Can I at least get their username and course if they are logged in and actively in the course?

Basically, when a student clicks a link I am taking them to another page. At that point I want to capture their name, course ID and e-mail address instead of relying on them to enter this information and potential mispell something in turn breaking later functionality.

Web service to create Notes under a selected course

$
0
0
by Dominic John.  

Hi All,

Can somebody help by telling the web service to be used to create a Note for a course.

I tried using "core_notes_create_notes" and it gives me the following exception,

<EXCEPTION class="webservice_access_exception">
<ERRORCODE>accessexception</ERRORCODE>
<MESSAGE>Access control exception</MESSAGE>
</EXCEPTION>

tried "moodle_notes_create_notes" and it gives me the following exception,

<EXCEPTION class="invalid_parameter_exception">
<ERRORCODE>invalidparameter</ERRORCODE>
<MESSAGE>Invalid parameter value detected</MESSAGE>
</EXCEPTION>

 

Trying to do this from Android.

Able to consume the following web services, login and get_my_courses both returened proper responses.

 

Following is the code snippet.

public class moodle_login extends Activity {
Button btnLogin;
EditText edtusername, edtpwd, edtlog;
String sUsername, spwd;
String sessionkey, clientID;

@Override

protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);

setContentView(R.layout.mllogin);

btnLogin = (Button) findViewById(R.id.btnlogin);
edtusername = (EditText) findViewById(R.id.edtusername);
edtpwd = (EditText) findViewById(R.id.edtpwd);
edtlog = (EditText) findViewById(R.id.edtlog);

if (android.os.Build.VERSION.SDK_INT >= 11) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}

btnLogin.setOnClickListener(new View.OnClickListener() {

private String ConsumeWebservice( String sURL){

HttpClient httpClient = new DefaultHttpClient();

HttpPost post = new HttpPost(sURL);


List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);

nameValuePairs.add(new BasicNameValuePair("userid", "3"));

nameValuePairs.add(new BasicNameValuePair("publishstate", "site"));
nameValuePairs.add(new BasicNameValuePair("courseid", "2"));
nameValuePairs.add(new BasicNameValuePair("text", "This is a teacher site-wide note about the user"));
nameValuePairs.add(new BasicNameValuePair("format", "FORMAT_PLAIN"));
nameValuePairs.add(new BasicNameValuePair("clientnoteid", "note_3"));




try {
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

// Execute HTTP Post Request
HttpResponse responseX = null;
try {
responseX = httpClient.execute(post);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

String respStr = null;
try {
respStr = EntityUtils.toString(responseX.getEntity());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return respStr;
}

public void onClick(View v) {
String surl;
String respStr;
String wstoken;
String wsfunctionName;
JSONArray jArray;
JSONObject json;

//sUsername = "dominic";
//spwd = "Dominic1!";

sUsername = "admin";
spwd = "Dominic1!";

wstoken = "09d6da7bb2d6e5a561a500b9dd50b3b4";


try{
wsfunctionName = "login";
surl = "http://192.168.56.1/moodle/wspp/service_pp2.php?username=" + sUsername + "&password=" + spwd + "&wsfunction=" + wsfunctionName + "&wsformatout=json";
respStr = ConsumeWebservice (surl);
//Parse output
json = new JSONObject(respStr);
sessionkey = json.getString("sessionkey");
clientID = json.getString("client");


wsfunctionName = "get_my_courses";
surl = "http://192.168.56.1/moodle/wspp/service_pp2.php?%20client=" + clientID + "&sesskey=" + sessionkey + "&wsfunction=get_my_courses&wsformatout=json";
respStr = ConsumeWebservice(surl);
//Parse Courses
if (respStr != "") {
jArray = new JSONArray(respStr);

for(int i=0;i<jArray.length();i++)
{
JSONObject jsonObject = jArray.getJSONObject(i);
edtlog.append(jsonObject.getString("shortname"));
edtlog.append(jsonObject.getString("fullname"));
edtlog.append("============");
}
}

//Post a note to a course
wsfunctionName = "moodle_notes_create_notes";//"moodle_notes_create_notes";//"core_notes_create_notes";
//surl = "http://192.168.56.1/moodle/webservice/rest/server.php?%20client=" + clientID + "&sesskey=" + sessionkey + "&wsfunction=" + wsfunctionName + "&wsformatout=json" + "&token=" + wstoken + "&format=json" + "&wstoken=" + wstoken;
surl = "http://192.168.56.1/moodle/webservice/rest/server.php?%20wsfunction=" + wsfunctionName + "&wsformatout=json" + "&token=" + wstoken + "&format=json" + "&wstoken=" + wstoken;
respStr = ConsumeWebservice(surl);

}
catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}
});




}

 


Re: Web service to create Notes under a selected course

$
0
0
by Joshua Johnston.  

I am by no means an expert but when I ran across an access control exception it is because I forgot to add the method to the service I created

Enhancement to core_group_get_groupings

$
0
0
by Paul Charsley.  

Hi Everyone,

We are proposing an enhancement to the web service function core_group_get_groupings and have started work on this in MDL-36541. The enhancement will allow the groups associated with the requested grouping to also be returned (an optional parameter is set).

We intend to use this so that a web service client can get the members of the teams in a team assignment in the new assignment module. The mdl_assign table has a field that holds the teamsubmissiongroupingid and this value is passed as a parameter to the modified function.

Any feedback would be welcome,

Paul

Re: local_wstemplate_hello_world Error: "You cannot view the profile of this user"

$
0
0
by Oliver Obermayr.  

... go to Site Administration > Users > Permissions > Define Roles, then double click your web services role,...

@Chris C, just wanted to clarify, what do you mean by "web services role", because I can't find this thing in my Moodle (v.2.4) in Site Administration > Users > Permissions > Define Roles. If you mean list of roles, then I have there Student Role, and I already allowed moodle/user:viewdetails by editing named role. But result is wihtout any affect. Could you help me with this?  Thank you

Re: local_wstemplate_hello_world Error: "You cannot view the profile of this user"

$
0
0
by john saylor.  

you have to create this role.

the webservices role is assigned to the webservices account used to run any of the functions. it has unique permissions because of the special nature of the functions it calls.

Re: OKTech Web Services

$
0
0
by Mike Churchward.  

I don't believe that code has ever been updated to work with Moodle 2. Moodle 2 has web services as part of its native code base, but they are not the same.

mike

Viewing all 2366 articles
Browse latest View live


Latest Images

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