Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sending Orders with XML to HTTPS


tinyvibes

Recommended Posts

Posted

Hello...

 

We send orders to our warehouse from OSC using a cron job and php. The warehouse just told me I need to start posting to HTTPS instead. But when I tried simply adding the S to HTTP in the variable, no dice. I get errors. How do I post to HTTPS?

 

Here is my code for posting XML from PHP. I've searched and search and can't find the answer... thnx!

 

function processXML($xmlSource) {

$host = "production.xxwarehousexxx.com";

$fp = fsockopen($host, 80, $errno, $errstr, 30);

if (!$fp) {

echo "Failed!\n";

echo $errstr($errno)."\n";

} else {

$out = "POST /mycompany/ProcessXML.aspx HTTP/1.0\r\n";

$out .= "Host: $host\r\n";

$out .= "Content-Type: text/xml\r\n";

$out .= "Content-Length: ".strlen($xmlSource)."\r\n";

$out .= "Connection: Close\r\n";

$out .= "\r\n";

$out .= $xmlSource;

fwrite($fp, $out);

$result = '';

while (!feof($fp)) {

$result .= fgets($fp, 128);

}

//return $result;

fclose($fp);

 

echo "==================RESPONSE:==================\n";

echo "\n$result\n";

echo "==================END RESPONSE:==================\n\n\n";

 

 

if(strstr($result, "Success")) {

return 1;

} else {

return 0;

}

 

}

Posted

Make a copy of this script on your server, name it myenv.php:

 

<?php
echo 'HTTP HOST: ' . "$HTTP_HOST";
echo '<br>Server Port: ' . getenv('SERVER_PORT');
echo '<br>SSL Status: ' . getenv('HTTPS');
echo '<br>Fowarded Server: ' . getenv('HTTP_X_FORWARDED_SERVER');
echo '<br>Fowarded Host: ' . getenv('HTTP_X_FORWARDED_HOST');
echo '<br>Fowarded By: ' . getenv('HTTP_X_FORWARDED_BY');
?>

To give credit where credit is due, that script is from this post:

 

myenv.php

 

Access is with an HTTPS URL, like:

 

https://www.yoursite.com/myenv.php

The HTTPS is of the utmost importance!!!!

 

Whatever it returns for the value for SERVER_PORT, most likely 443, put that number in the next line of your code, instead of the 80

 

$fp = fsockopen($host, 80, $errno, $errstr, 30);

Let me know how this turns out.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Posted

Ok, great. Thanks! Yes, it did return 443.

 

So in addition to changing this line: $fp = fsockopen($host, 443, $errno, $errstr, 30);

 

do I also add the S to this one now?

 

$out = "POST /mycompany/ProcessXML.aspx HTTPS/1.0\r\n";

 

sorry if obvious question

Posted

I'd try it first without the S added there.

 

If it doesn't work, then add the S there.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...