Advertisement
Guest User

Untitled

a guest
Feb 24th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. function form_fun_cake_submit(&$form, &$form_state) {
  2. $serverUrl=' http://localhost/moodle/my/webservice/rest/server.php?wstoken=d90b5d90db13711d12df525366f15db1';
  3.  
  4. $functionName = 'core_user_create_users';
  5. $user1 = new stdClass();
  6. $user1->username = 'testusername1';
  7. $user1->password = 'Uk3@0d5w';
  8. $user1->firstname = 'testfirstname1';
  9. $user1->lastname = 'testlastname1';
  10. $user1->email = 'testemail1@moodle.com';
  11. $user1->auth = 'manual';
  12. $user1->idnumber = '';
  13. $user1->lang = 'en';
  14. $user1->timezone = 'Australia/Sydney';
  15. $user1->mailformat = 0;
  16. $user1->description = '';
  17. $user1->city = '';
  18. $user1->country = 'AU'; //list of abrevations is in yourmoodle/lang/en/countries
  19. $preferencename1 = 'auth_forcepasswordchange';
  20. $user1->preferences = array(
  21. array('type' => $preferencename1, 'value' => 'true')
  22. );
  23.  
  24. $users = array($user1);
  25. $params = array('users' => $users);
  26.  
  27. /// REST CALL
  28. $rest_format = 'json';
  29.  
  30. //$server_url = $domain_name . '/webservice/rest/server.php' . '?wstoken=' . $token . '&wsfunction=' . $function_name;
  31. $server_url = 'localhost/moodle/my' . '/webservice/rest/server.php'. '?wstoken=' . '15bd45a3dab2958b7e8fc237b14f76cd' .'&wsfunction='. $functionName;
  32. dpm($server_url);
  33. require_once('curl.inc');
  34. $curl = new curl;
  35. $rest_format = ($rest_format == 'json') ? '&moodlewsrestformat=' . $rest_format : '';
  36.  
  37. $resp =$curl($server_url . $rest_format, $params); //This is my line no 78
  38. dpm($rest_format);
  39. $respRc = json_decode($resp, true);
  40.  
  41.  
  42.  
  43.  
  44. dpm($resp);
  45.  
  46.  
  47. echo '</br>************************** Server Response createUser()**************************</br></br>';
  48. echo $server_url . '</br></br>';
  49.  
  50. var_dump($resp);
  51.  
  52.  
  53.  
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement