PHP converter para Java

Olá pessoal, se alguem aqui entender um pouco de PHP e puder me ajudar …
Tenho que acessar que fazer em java a mesma coisa que essa classe em PHP faz, … o problema q conheço bolhufas de PHP …

Se alguem puder me ajudar … :slight_smile:

[code]<?php

class xmlSender {

/**
 * Constructor
 * Verify if the cURL is available 
 */
function xmlSender()
{
	if ( !extension_loaded('curl') ) {
		trigger_error("You need cURL loaded to use this class", E_USER_ERROR);
	}
}

/**
 * Sends the xml content using the cURL library.
 */
function send( $str_xml, $str_url, $str_page, $boo_ssl = false )
{
	$str_header  = "POST " . $str_page . " HTTP/1.0 \r\n";
	$str_header .= "MIME-Version: 1.0 \r\n";
	$str_header .= "Content-type: application/PTI26 \r\n";
	$str_header .= "Content-length: " . strlen($str_xml) . " \r\n";
	$str_header .= "Content-transfer-encoding: text \r\n";
	$str_header .= "Request-number: 1 \r\n";
	$str_header .= "Document-type: Response\r\n";
	$str_header .= "Interface-Version: InPhonex 1.0 \r\n";
	$str_header .= "Connection: close \r\n\r\n";
	$str_header .= $str_xml;

	$res_curl = curl_init();
	curl_setopt($res_curl, CURLOPT_URL, $str_url);
	curl_setopt($res_curl, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($res_curl, CURLOPT_TIMEOUT, 30);    
	curl_setopt($res_curl, CURLOPT_CUSTOMREQUEST, $str_header);
	curl_setopt($res_curl, CURLOPT_FOLLOWLOCATION, 1);
	
	if ( $boo_ssl ) {
		curl_setopt($res_curl, CURLOPT_SSL_VERIFYHOST,  0);
		curl_setopt($res_curl, CURLOPT_SSL_VERIFYPEER, false);
	} 
	
	$str_data = curl_exec($res_curl);
	if ( curl_errno($res_curl) ) {
	   trigger_error(curl_error($res_curl), E_USER_ERROR);
	} else {
	   curl_close($res_curl);
	}
	
	return $str_data;
}

}

$str_xml = ‘’ .
‘’ .
‘<customer_id>customerid</customer_id>’ .
‘password’ .
‘’ .
‘’ .
‘<request_id>query</request_id>’ .
‘<query_id>cdr</query_id>’ .
‘\n’ .
‘<start_date>2006-06-22</start_date>\n’ .
‘<end_date>2006-06-22</end_date>\n’ .
‘\n’ .
‘’ .
‘’;

$o = new xmlSender;
print_r($o->send($str_xml, “https://www.inphonex.com”, “/API/1.0/”, true));
?>[/code]

Uma coisa que eu percebi, é passado uma String no formato XML para o método send … mas o resto … :cry:

Valewww

Documentação:

http://www.php.net/manual/pt_BR/ref.curl.php

http://www.php.net/manual/pt_BR/function.trigger-error.php

http://www.php.net/manual/pt_BR/function.extension-loaded.php

É um emissário XML, que pega algumas propriedades, coloca dentro de um client URL e manda para o site.

Até!