Ejemplo n.º 1
0
 static function call_method_debug_curl($method, $params = CJ_EMPTY_VALUE, $params2 = CJ_EMPTY_VALUE)
 {
     $moodle_xmlrpc_server_url = JoomdleHelperContent::_get_xmlrpc_url();
     //$request = xmlrpc_encode_request("auth/joomdle/auth.php/$method", array ($params, $params2));
     $request = JoomdleHelperContent::get_request($method, $params, $params2);
     $headers = array();
     array_push($headers, "Content-Type: text/xml");
     array_push($headers, "Content-Length: " . strlen($request));
     array_push($headers, "\r\n");
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $moodle_xmlrpc_server_url);
     # URL to post to
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     # return into a variable
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     # custom headers, see above
     curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
     # This POST is special, and uses its specified Content-type
     $response = curl_exec($ch);
     # run!
     curl_close($ch);
     $response = xmlrpc_decode($response);
     /*		if (is_array ($response))
     			if (xmlrpc_is_fault ($response))
     			{
     				echo "XML-RPC Error (".$response['faultCode']."): ".$response['faultString'];
     				die; // XXX Something softer?
     			}
     */
     return $response;
 }