Created
September 23, 2013 12:29
-
-
Save jleyva/6669774 to your computer and use it in GitHub Desktop.
Testing core_user_add_user_device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This file is NOT a part of Moodle - http://moodle.org/ | |
// | |
// This client for Moodle 2 is free software: you can redistribute it and/or modify | |
// it under the terms of the GNU General Public License as published by | |
// the Free Software Foundation, either version 3 of the License, or | |
// (at your option) any later version. | |
// | |
/** | |
* REST client for Moodle 2 | |
* Return JSON or XML format | |
* | |
* @authorr Jerome Mouneyrac | |
*/ | |
/// SETUP - NEED TO BE CHANGED | |
$token = '08f6b5b5527afd672d832bd7375903ec'; | |
$domainname = 'http://localhost/moodle'; | |
$functionname = 'core_user_add_user_device'; | |
// REST RETURNED VALUES FORMAT | |
$restformat = 'json'; //Also possible in Moodle 2.2 and later: 'json' | |
//Setting it to 'json' will fail all calls on earlier Moodle version | |
$params = array('appid' => 'com.moodle.moodlemobile', | |
'name' => 'occam', | |
'model' => 'Nexus 4', | |
'platform' => 'Android', | |
'version' => '4.2.2', | |
'pushid' => 'apushdkasdfj4835', | |
'uuid' => 'asdnfl348qlksfaasef859' | |
); | |
/// REST CALL | |
header('Content-Type: text/plain'); | |
$serverurl = $domainname . '/webservice/rest/server.php'. '?wstoken=' . $token . '&wsfunction='.$functionname; | |
require_once('./curl.php'); | |
$curl = new curl; | |
//if rest format == 'xml', then we do not add the param for backward compatibility with Moodle < 2.2 | |
$restformat = ($restformat == 'json')?'&moodlewsrestformat=' . $restformat:''; | |
$resp = $curl->post($serverurl . $restformat, $params); | |
print_r($resp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment