Sending string containing angle brackets

I am trying to send a string containing angle brackets ("<" and “>”) via POST. No matter what I do, PHP strips the brackets and the text between them from the text sent. I am POSTing to a remote application that requires the literal brackets, it will not accept < and >. I have tried single quotes, double quotes and the backslash escape character to no avail.

[php]
$data=“data”;
$url = ‘https://Axxxxxxxxxx’;
$opts = array(‘http’ => array (‘method’ => ‘POST’,‘header’ => “Content-type: text/xml; charset=UTF-8”, ‘content’ => $data) );
$context = stream_context_create($opts);
[/php]
Only the word “data” is sent.

The same thing happens with a form
[php]

[/php] Echo to be understood beginning each line.

The entire string “data” can be saved to a file, but simple will not pass through the POST.

Is there anything that can be done?

Thanks.

If the same happens with a form, are you sure it’s not the remote end that’s stripping the characters? Have you tried POSTing the data to a local PHP form to see what gets sent?

Yes, I have tried sending to a local page. The literal brackets get stripped, although the < version works.

Does the remote application provide any way of solving this issue? Do they provide examples in PHP or another programming language of how to POST data to their service?

Also, have you tried using a different method of POSTing the data, for example cURL?

They have provided sample standalone programs in C++ and VB6 that work. I do not have access to the source. And they do not have anything that can be used for form processing, which is what I need to do.
They also claim they’re not aware of anyone trying PHP, which I find hard to believe.
cURL has been suggested, and it’s next on my list to investigate. But php.net’s examples are written for people who already know what they’re doing and are quite tedious to try to learn from. The sites returned on Google likewise are not generally for rank (and I do mean rank) beginners. And I’m running ot of time.
I’m also trying Perl with LWP and having one b*tch of a time. None of the docs or examples I can find agree with each other as far as syntax.

This is what I use:

[php] function post_request($url, $post_data) {
// Initialise curl
$curl = curl_init($url);

	// Set options
	curl_setopt_array($curl, array(
		CURLOPT_FOLLOWLOCATION => true,
		CURLOPT_MAXREDIRS => 3,
		CURLOPT_HEADER => false,
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_CONNECTTIMEOUT => 3,
		CURLOPT_POST => 1,
		CURLOPT_POSTFIELDS => $post_data
	));

	// Execute request
	return curl_exec($curl);
}[/php]

$post_data should just be an array in key => value format. It returns the response from the server.

Well, it hasn’t crashed and it’s not giving me any errors, but neither is it giving me any positive results, like any kind of a return from the remote site.
I’m not sure I’m clear on “$post_data should just be an array in key => value format”. The data is a single (although long) string.

Oops, I misread what you put! How does the remote service receive the data then? Do they ask for a certain field? I don’t know how else the data would be sent.

Oops as well. I didn’t make that clear. The data is a single string, sort of like this:
“datadatadatadatadataG>datadatadatadata”

Do they say it’s a certain protocol or way of sending the data? The only thing that I’ve read about that comes to mind is XML RPC. Does that sound familiar?

The following is from the remote site’s documentation (it’s a credit card processor, so I’ve removed the real URL). Even though I don’t understand these languages, it seems to me that the only things required are the URL, the content_type header and the data string. There is no mention of any prorocols except HTTPS POST.

  1. Submit the transaction request string

Once the string has been built, submit the string to the xxx URL
(https://xxx.aspx) using a secure HTTPS POST operation. When submitting the string, the request header parameter must be set to text/xml.

Examples
The following is an example of how to submit a request string to xxx using ASP and Microsoft XML version 3.0 (msxml3.dll):
Set objXML = Server.CreateObject(“Msxml2.ServerXMLHTTP”) strURL = https://xxx…aspx objXML.Open “POST”, strURL, False objXML.SetRequestHeader “Content-Type”, “text/xml” objXML.Send (strXML) „submits the string created by the BuildMessage function

The following is an example of how to submit a request string to xxx using Visual Basic and Microsoft WinHTTP Services version 5.1 (winhttp.dll):
Dim objHTTP As New WinHttp.WinHttpRequest strURL = https://xxx.aspx objHTTP.Open “POST”, strURL, False objHTTP.SetTimeouts 4000, 4000, 5000, 90000 objHTTP.SetRequestHeader “Content-Type”, “text/xml” objHTTP.Send (strXML) „submits the string created by the BuildMessage function

BTW, I have been able to connect with the perl/LWP method I mentioned before.
Frankly, since cURL is part of PHP, I don’t see how it possibly could handle the string any different.

Can you provide the name of the credit card processor?


In addition to this, try using my cURL function from above yet make $post_data contain just the raw data you are trying to send, not an array.

Verifone, using their PAYware Connect suite.

I’ve tried just the string with the same results, a blank screen.
Is there something I’m missing about receiving a return of some sort?

The function returns the result. So:

[php]$result = post_request(‘some-site.com’, ‘</xml’);

echo $result;[/php]

OK. I put these lines after the function call in the body, where I assume the function returns to. I replace ‘some-site.com’ with the URL I originally called the function with. I fail to grasp the xml tags. Just using the original data string still results in a blank screen. Using the xml tags (after I added the closing “>”, with or without the data also does nothing.
I may be dreaming of a white Christmas, but a white computer screen is not pleasant.
I appreciate your efforts beyond words, but I don’t think we’re going to get anywhere here.

I’m afraid that’s all I can think of! If they don’t even give you an error, there’s not a great deal you can do.

Sponsor our Newsletter | Privacy Policy | Terms of Service