Page 1 of 1
An HTTP request.
Posted: Fri Aug 24, 2007 12:40 pm
by JellyFish
Code: Select all
<?php
function HttpRequest($address, $data)
{
$url = parse_url($address);
while (list($key, $value) = each($data))
{
$dataToPost .= "$key=$value&";
}
$dataToPost = rtrim($dataToPost, "&");
$request = "POST ".$url['path']." HTTP/1.0\r\n"
. "Host: ".$url['host']."\r\n"
. "Content-Type: application/x-www-form-urlencoded;\r\n"
. "Content-Length: ".strlen($dataToPost)."\r\n"
. "\r\n"
. $dataToPost;
$socket = @fsockopen($url['host'], 80, $errno, $errstr) or die("Error: unable to open a socket connection with ".$url['host']."\n $errno: $errstr");
fwrite($socket, $request);
// Response
$response = '';
while (!feof($socket)) {
$response .= fpassthru($socket);
}
fclose($socket);
return $response;
}
?>
Code: Select all
HttpRequest("https://www.linkpointcentral.com/lpc/servlet/lppay", $anArray);
My question is: Would the above call to the function HttpRequest post $anArray to "
https://www.linkpointcentral.com/lpc/servlet/lppay"?
Posted: Fri Aug 24, 2007 12:50 pm
by VladSun
I don't see any problems - have you tried it?
Posted: Fri Aug 24, 2007 1:00 pm
by JellyFish
VladSun wrote:I don't see any problems - have you tried it?
Yeah, this is the response I get:
Are you familiar with link point?
Posted: Fri Aug 24, 2007 4:12 pm
by feyd
HTTPS (SSL) does not communicate on port 80 by default. It uses 443, if memory serves.
Posted: Fri Aug 24, 2007 4:44 pm
by JellyFish
feyd wrote:HTTPS (SSL) does not communicate on port 80 by default. It uses 443, if memory serves.
When I changed the port number:
Code: Select all
$socket = @fsockopen($url['host'], 443, $errno, $errstr) or die("Error: unable to open a socket connection with ".$url['host']."\n $errno: $errstr");
I get:
Posted: Fri Aug 24, 2007 4:47 pm
by feyd
Did you read the documentation for the function a little more on SSL?
Posted: Fri Aug 24, 2007 4:59 pm
by JellyFish
feyd wrote:Did you read the documentation for the function a little more on SSL?
Which function, which documentation. I don't know of any SSL documentation, I guess now would be a good time to ask for some good resources.
But other then the port number does everything else look alright like it would send the data in the right format and get the full response?
Posted: Fri Aug 24, 2007 9:47 pm
by feyd
....
fsockopen()'s documentation states a few things about SSL pretty quick..