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

Login using REST webservice

$
0
0

by Rajapandian S.  

Hi,

I had created manual webservice called login_check. Which is used to check the given/passed username and password is correct/wrong.

I passed the credentials from the core php file. If the credentials is valid, then the user have to logged in to the moodle site.

Now the values are passed into the function login_check(in moodle server) by REST url from core PHP file to moodle server.

User authenticate is successful and I got return success message but session is not maintained in the moodle server.

After user validate I opened login form in moodle server in the new tab of the browser, it is still not logged in and shows me login form. If my validate is correct it has to open the login page with two confirm button.

I dont know what I did wrong. 


public static function login_check($userdata) {

        global $DB,$CFG;        

        $params = self::validate_parameters(self::login_check_parameters(), array('userdata'=>$userdata));

        $dbauth = get_auth_plugin('webservice');

        $user_valid = $dbauth->user_login_webservice($userdata['username'], $userdata['password']);

        if($user_valid){

              $userss = authenticate_user_login($userdata['username'], $userdata['password']);

              $user1 = get_complete_user_data('id', $userss->id);

              complete_user_login($user1);

              \core\session\manager::apply_concurrent_login_limit($user1->id, session_id());

              if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) == 0)) {

                     // the URL is set and within Moodle's environment

                    $urltogo = $SESSION->wantsurl;

                     unset($SESSION->wantsurl);

               } else {   // no wantsurl stored or external link. Go to homepage.

                      $urltogo = $CFG->wwwroot . '/';

                      unset($SESSION->wantsurl); 

               }

              if (isloggedin()) {

                           return 'Login Success';

                }

             return 'Login failed';

   }else{

         return 'Login failed';

   }

}

For the above code I always get 'Login Success' message. For the user(send from core PHP) auth method is manual. In the user table, fields like "lastlogin,lastaccess,currentlogin" are updated everytime when I send request for core PHP.


Please help me guys.


Public IP and Private IP in moodle server accessing from outside

$
0
0

by raj singh.  

Hi, 

I have installed my moodle in windows server 2012 with IP address 192.168.0.3 and local host url is campusmoodle.ng. Its working fine with WIFi and LAN. But if i want to access my local server outside i.e from my home with internet. How this could be done? Please provide me all necessary settings required. 

Raj  

Website speed check

$
0
0

by 10key things.  

i have problem with my website, it's loading speed is very slow plz suggest me what's the problem and how i increase my website loading speed.   

Re: XML-PRC: trouble using webservice core_completion_get_activities_completion_status

$
0
0

by Jannik Olsen.  

Just wanted to share my solution, in case anyone else has this problem.

Turns out it was indeed the xml structure. Enabling verbose error messages enabled me to customize the xml so it was finally accepted (see below). However, I cannot for the life of me figure out how to make the PHP functions create this XML, so for now I'll have to accept making it manually. Not that it's a big issue but it's still annoying, and I would love if someone could enlighten me on this.

Working XML:

<?xml version="1.0" encoding="iso-8859-1"?><methodCall><methodName>core_completion_get_activities_completion_status</methodName><params>
 <param><value><courseid><int>2257</int></courseid></value></param>
 <param>
  <value>
     <userid><int>7619</int></userid>
  </value>
 </param></params></methodCall>

No API to create an assignment/module

$
0
0

by Noora C.  

Using the webservices API I'm able to create course pages, edit topic titles, and do most other tasks I need remotely. But one essential thing I can't do is create a new lesson through the API, or any other module/assignment, for that matter.

I checked the MDL tracker and it's on the roadmap, but it's been on the roadmap since 2013 with only a few updates. Ref: MDL-40779.

It may be another several years before it's rolled out for production. In the meantime, I've tried calling the /mod/lesson/lib.php file directly to access the functions in there, but due to the autoloader and security restrictions, that gets stopped in it's tracks. I've also tried uploading a custom php file to the Moodle directory that takes a few GET parameters and calls the add_lesson_instance() function itself. I then tried calling that file through cURL remotely, but it's a no go. I'm playing whack-a-mole with an endless runaround of errors.

Has anyone found a solution for creating an assignment or module remotely, outside of Moodle?


EDIT: I've also been playing around with modifying the Joomdle plugin since it creates it's own custom API calls in Moodle, but if the developers of this plugin haven't been able to do it themselves, then I don't have much hope.

Re: use web services to upload a file and get it

Re: Can not find data record in database table external_functions

$
0
0

by Noora C.  

To be honest, I'm not sure if anyone has gotten a working prototype up using this template. At least I haven't found one. According to the developer himself on Github:

"I agree these examples should be polished out a bit. It is important to understand that they are not supposed to work as out-of-box tutorials themselves."

He then goes on to mention that it's quite complicated to get a new webservice up and running. After spending several days trying to get it working, I have to agree, as I still haven't got it working.

Re: update course section description/title

$
0
0

by Noora C.  

I just got this working today. You need to first call the function you mentioned 'core_course_get_contents' to get the id's of each section/topic within the course. 

Once you get the sectionid of of the section/topic you need to update, create an array (assuming you're using PHP). If you're changing the topic title, do something like this:

$temp = array();
$temp['component'] = 'format_topics';   // If the course is formatted using topics
$temp['itemtype'] = 'sectionname';
$temp['itemid'] = [THE_ITEM_ID]; // the section id returned by the core_course_get_contents function
$temp['value'] = [YOUR_NEW_TITLE]; // can't be an empty string, or it won't update

Then just end the above array over and it should update the topic title.



Re: Can anyone here help me in integration peoplesoft with moodle

Re: user field updated through web service

Re: How To implement SOAP content encrypt / decrypt by using x.509 certificate Cryptography.

Re: How To make the system/ Application with an integration to WS-security Axis 2 Ready

Re: Course Return null

Re: Webservice

$
0
0

by Deepak Gour.  

Hi Kritika 


Please see this video for more understand.


Writing SCORM track data in web service scenario

$
0
0

by Mark Achten.  

We're developing a custom learning app for a client. That client uses Moodle as an LMS and we're expected to write course progress and results back to Moodle using standard Moodle web services. The course is configured as a SCORM typed course. 

To set up the web services we basically we saw two options:

  • set up web service permissions for each and every user enrolled in that course.
  • set up a dedicated web service user account

We chose the second option (less configuration needed) but ran into the fact that writing data is performed under the current logged on user. So writing progress data in table 'mdl_scorm_scoes_track' is recorded with the userId of the generic web service user. The web service does not take a 'userId' parameter. (see here.)

As I see it now, there is no way to get the second option working. Question to the community: please confirm that the default web service for writing SCORM track data does not support the scenario of using a generic web service user. If I'm mistaken, what am I not seeing?

As for the first option: what would be the most efficient setup to get the app working when faking the web service calls under the account of the current user.

Thanks to all!


Calling auth_userkey_request_login_url function using REST API

$
0
0

by Philippe Requet.  

Hello,

Sorry for my english, i'm french and i'm having a problem using curl...

Here is my code (i saw it on another post on this forum) :

require_once('../src/dcai/curl.php');

    $token        = 'b98c67341a308b9cffd692b5b300b306';

    $domainname   = 'http://testals.arkesys.fr';

    $functionname = 'auth_userkey_request_login_url';

$idnumber = array( 'key' => 'idnumber' ,  'value' => 2 );

$params = array( 'criteria' => array($idnumber));

$server_url = $domainname . '/webservice/rest/server.php' . '?wstoken=' . $token . '&wsfunction=' . $functionname;

$curl = new dcai\curl();

$rest_format = '&moodlewsrestformat=json';

$resp = $curl->post($server_url . $rest_format, $params);

$resp     = json_decode($resp);

$loginurl = $resp->loginurl;


But if i try, i have an error :

 Undefined property: stdClass::$loginurl in D:\WampInstall2\wamp64\www\moodleold\Test\PNTest\curl-master\examples\test.php on line 43


Do you know how i can get the login URL, and where is my error ?

Thanks for your help, i'm lost...

External application interaction with Moodle 1.9.13

$
0
0

by Andrew Go.  

Hi all!

For analytics tasks we just need to execute some sql queries from remote computer to our Moodle database.


Please can you tell me how better to achieve this goal?

How to enable web services with Moodle 1.9.13 ?

I can't find the Plugins->Web services menu item for enabling web services and swithcing protocols settings and generating token settings for remote third-party clients.


And is it possible to create third-party rest\soap (probably xml-rpc) client application on java\python\javascript without writing php server side code (except business logic functions of course)?

I don't know php at all. But probably i could write simple functions that should be calling from remote computer for sql queries executing.


Besides we can't upgrade Moodle to 2.0 due to old plugins that i should using.

Thank you for your time and sorry for my language level!

Re: External application interaction with Moodle 1.9.13

$
0
0

by rahul rai.  

Hello Andrew

For enable web services in moodle 1.9 you need to follow path.

Settings block > Site Administration > Plugins > Web services > External Services.

Select Authorized users link.

Select the created user and click Add.


Create a token


 Settings block > Site Administration > Plugins > Web services > Manage tokens
 Click on Add
 Select the created user and service
 Click on Saves changes

Re: External application interaction with Moodle 1.9.13

$
0
0

by Andrew Go.  

Hello, Rahul!


I can't find that menu items, please see the screenshot below. This is our test Moodle server.

Re: External application interaction with Moodle 1.9.13

$
0
0

by rahul rai.  

Hi Andrew

It is better to upgrade your moodle version.

Do not worry about old version plugins. It also you can upgrade. 


Viewing all 2364 articles
Browse latest View live


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