473,889 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

fsockopen problem

Hi, I am trying to complete a post using fsockopen but I'm getting the
following error:

"Unable to find the socket transport "ssl" - did you forget to enable
it when you configured PHP?

I am running php 5.1.4 with apache 2 on fedora core 4. When I
configured php I did it like this:
../configure --with-apxs2=/usr/sbin/apxs --with-mysql

All I'm trying to achieve is to get a response from the neteller test
server, the response will be an error as the numbers I'm sending it are
garbage, but I'm not bothered about that, I just want to be able to
send the request and get the response back. I've searched google for a
while but can't figure out why my code isn't working, I know there were
problems with windows platforms with php4 but obviously, that is not an
issue here...
Thanks in advance, my code is below...
Angus

<?php
//SIMULATES A (HTTP POST) FORM SUBMISSION
//www.zend.com/zend/spotlight/mimocsumissions .php
//takes 2 parameters: associative array containing data to be sent to
server, DNS or IP of server
//returns $result array with lines of response
function post_it($datast ream, $url)
{
//replace http:// with the empty string, get host, get resource
$url = preg_replace("@ ^https://@i", "", $url);
$host = substr($url, 0, strpos($url, "/"));
$uri = strstr($url, "/");

//construct request body: vars and their values
$reqbody ="";
foreach ($datastream as $key => $val)
{
if (!empty($reqbod y))
$reqbody .= "&";
$reqbody .= $key."=".urlenc ode($val);
}

//construct post request to be sent to server, include size of reqbody
$contentlength = strlen($reqbody );
$reqheader = "POST $uri HTTP/1.0 \r\n";
$reqheader .= "Host: $host\n";
$reqheader .= "User-Agent: PostIt\r\n";
$reqheader .= "Content-Type: application/x-www-form-urlencoded\r\n" ;
$reqheader .= "Content-Length: $contentlength\ r\n\r\n";
$reqheader .= "$reqbody\r \n";

//connect to server, send POST request, read result, close socket
$socket = fsockopen("ssl://".$host, 443, $errno, $errstr);

if (!$socket)
{
echo "host: ".$host."<b r>";

echo "<p>&nbsp;</p>";

$result["errno"] = $errno;
$result["errstr"] = $errstr;
return $result;
}
fputs($socket, $reqheader);
while (!feof($socket) )
{
$result[] = fgets($socket, 4096);
}
fclose($socket) ;
return $result;
}
?>

<HTML>
<HEAD>
<TITLE>NETell er Transfer</TITLE><META HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<BODY>
<?php
$data["merchant_I D"] = 123;
$data["merch_tran sid"] = 123;
$data["test"] = 1;
$data["amount"] = 123;
$data["currency"] = "USD";
$data["net_accoun t"] = 123;
$data["secure_id"] = 123;

$result = post_it($data,
"https://www.neteller.co m/gateway/netdirectv4.cfm ");

if (isset($result["errno"])) {
$errno = $result["errno"];
$errstr = $result["errstr"];
echo "<B>Error $errno</B> $errstr";
exit;
}
else {
for($i = 0; $i < count($result); $i++)
echo $result[$i];
}
?>
</BODY>
</HTML>

May 20 '06 #1
6 45924
tim

mu**@hotmail.co .uk wrote:
Hi, I am trying to complete a post using fsockopen but I'm getting the
following error:

"Unable to find the socket transport "ssl" - did you forget to enable
it when you configured PHP?

I am running php 5.1.4 with apache 2 on fedora core 4. When I
configured php I did it like this:
./configure --with-apxs2=/usr/sbin/apxs --with-mysql


Hi

My guess is that either mod_ssl is not installed for apache or it is
installed but the configuration lines for mod_ssl are commented out in
httpd.conf (like it was on suse9 for me). apxs will only enable ssl
functions in php if mod_ssl is up and running

So check mod_ssl is available + enabled in apache then try recompiling
php with

./configure --with-apxs2=/usr/sbin/apxs --with-mysql --enable-ssl

Tim

May 20 '06 #2
tim wrote:

mu**@hotmail.co .uk wrote:
Hi, I am trying to complete a post using fsockopen but I'm getting the
following error:

"Unable to find the socket transport "ssl" - did you forget to enable
it when you configured PHP?

I am running php 5.1.4 with apache 2 on fedora core 4. When I
configured php I did it like this:
./configure --with-apxs2=/usr/sbin/apxs --with-mysql


Hi

My guess is that either mod_ssl is not installed for apache or it is


Wrong. You are getting confused about servers and clients - mod_ssl is what
runs on the server. The OP is talking about the client end of an SSL
connection. I had a quick look at the PHP docs and it doesn't tell you the
option for client SSL. Trying with a copy of 5.0.4 I've got
handy, ./configure --help suggests:

--with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.6)

YMMV. Alternatively, as a quick hack, set up a stunnel connection.

C.
May 20 '06 #3
tim

Colin McKinnon wrote:
tim wrote:

mu**@hotmail.co .uk wrote:
Hi, I am trying to complete a post using fsockopen but I'm getting the
following error:

"Unable to find the socket transport "ssl" - did you forget to enable
it when you configured PHP?

I am running php 5.1.4 with apache 2 on fedora core 4. When I
configured php I did it like this:
./configure --with-apxs2=/usr/sbin/apxs --with-mysql


Hi

My guess is that either mod_ssl is not installed for apache or it is


Wrong. You are getting confused about servers and clients - mod_ssl is what
runs on the server. The OP is talking about the client end of an SSL
connection.


I know the difference but I failed to point out the difference clear in
my post and there are good resons in this case to make suggest mod_ssl
is installed.

The OP is going to be submitting details to neteller and I assumed they
will be submitted to him over the web.

When processing banking info over the web its best to have a secure
connection between the web browser->server/php script as well as
between the script/merchant bank. This would need mod_ssl installed in
the server as well as the ssl client functions enabled in php and this
is why I talked about mod_ssl in apache being needed.

Of course I should have said in my post that mod_ssl isnt needed to
enable the the ssl functions in php so thanks for pointing it out.

Tim

May 21 '06 #4
Thank you for the reply.... However, I forgot to mention in my
initial post that if I try it with a normal http post on port 80 it
still throws an error: Something like:

"Unable to find the socket transport "http" - did you forget to enable
it when you configured PHP?

Can someone check to see if the code I've got does actually send the
request and get a response on their system?

Thanks

May 21 '06 #5
tim

Eh Lit wrote:
Thank you for the reply.... However, I forgot to mention in my
initial post that if I try it with a normal http post on port 80 it
still throws an error: Something like:

"Unable to find the socket transport "http" - did you forget to enable
it when you configured PHP?

Can someone check to see if the code I've got does actually send the
request and get a response on their system?

Thanks


Its worked ok for ssl and port 80 on my gf's pc. There was a http 400
error but it was only a missing carriage return in $reqheader .= "Host:
$host\n";

My only suggestion is recompile php with --enable-sockets as well as
--with-openssl like Colin said earlier.

The full response from neteller was

<HTML>
<HEAD>
<TITLE>NETell er Transfer</TITLE><META HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<BODY>
HTTP/1.1 200 OK
Connection: close
Date: Sun, 21 May 2006 01:00:03 GMT
Content-Type: text/html; charset=UTF-8
Server: Microsoft-IIS/6.0 Geobytes-GeoSelect/2.1.0.1
Set-Cookie:
WEBTRENDS_ID=80 .192.149.30-3837753504.2978 5201::380E73529 3EA42E24D4975C6 BB5EC4EF;
path=/; expires=Mon, 21-May-2007 01:00:03 GMT

<?xml version="1.0" encoding="ISO-8859-1"?><netdire ct version="4.0">
<approval>no</approval>
<error>1020</error>
<custom_1>non e</custom_1>

<custom_2>non e</custom_2>
<custom_3>non e</custom_3>
</netdirect>

</BODY>
</HTML>

May 21 '06 #6
tim
Thank you for the reply.... However, I forgot to mention in my
initial post that if I try it with a normal http post on port 80 it
still throws an error: Something like:

"Unable to find the socket transport "http" - did you forget to enable
it when you configured PHP?
My only suggestion is recompile php with --enable-sockets as well as
--with-openssl like Colin said earlier.
I made a big mistake. I thought fsockopen was one of the socket
functions and needed enabling. It isn't. Its one of the network
functions and is always available.

By chance I got the exact same message you had when I tried
fsockopen('http ://servername.com' ,80) but itr workde when I tried
fsockopen('serv ername.com',80)
From the looks of http://uk.php.net/manual/en/transports.php the right

way to do a normal http request with fsockopen is using 'tcp://' not
'http://'.....Also tcp:// is assumed if by default if one isn't
specified and http:// isnt recognised.

Tim

May 21 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2783
by: Chris | last post by:
Hi All, I've been puzzling over this, but can't find a satisfactory answer anywhere. I'm not sure if the problem is in my code, or if it's something to do with the PHP/Apache set-up (probably the former as I am self taught, and probably taught myself a lot of bad habits). Anyway, the problem is this: I have a database with about 7,000 or so URLs stored in it (amongst other things). I need to check these URLs once a month or so and I...
2
3327
by: Colin Bell | last post by:
I'm stuck on a problem with getting data from a XML data stream. This stream is large and trying to use fsockopen to get the stream down. I've tetsed the code by telneting into the machine/port but I am getting some of the data but not all. I don't know the stream size. Code snippit below: function txrx($server, $port, $tx){
9
18704
by: fipaj1992 | last post by:
Hi! I have very big problem with fsockopen() function. It is very important... That's code: <?php $test = fsockopen ('chrome.pl', '8080'); ?>
1
5183
by: Syl | last post by:
Hi group - I have a database table with 4 columns that hold a url. I am selecting each url and I need to check to see if it is valid. I assumed I could use the fsockopen command. I've had to parse the url, since it cannot take the http:// Here is my testing code : $query = 'select id, reg, lurl, lurl_f, burl, burl_f from srl where id = 862 order by id';
1
23783
by: Henry16 | last post by:
Never seen such a situation ! Do you have once faced this problem ? We use a fsockopen to retrieve a content from a URL . The content is dispalid corretly on a page on one of our servers. But on an other server (more-or-less same config.) the content is not displaid !! with the error message :: Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed:
8
6196
by: Yoko | last post by:
So I am using php version 4.3.9 and lets say i have a file on the server called tester.php so i am using fsockopen to point to that file but it gives me a error below. $fh = @fsockopen("http://www.mysite.com/teter.php", "80", $errno, $errstr, 180);
6
6005
by: henryrhenryr | last post by:
Hi I'm really hoping for some ideas! I have been setting up phpmailer on my server and it was working nicely on my local server so I uploaded to my live server and tested. The mystery is that it times out. The timeout occurs with fsockopen(). I have checked the php configuration line by line and I can't find anything in the live server setup that is different from the local which might affect it. Could gmail have black-listed my...
0
10036
by: smokenlinks | last post by:
I am working on a script and i get this error Warning: fsockopen() : unable to connect to https://www.alertpay.com:443 (Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?) in XXXXXXXXXXXXXX on line 84 I have contacted my host to make sure that ssl and all that is enabled he says it has been enabled and it still dont work here is my server info http://www.performancebux.com/info.php If...
5
4005
by: aswathip | last post by:
I am new to sockets and fsockopen(). I am trying to send SMS using a gateway. But the fsockopen always shows the following error. Warning: fsockopen() : unable to connect to alertbox.in:80 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\wamp\www\pro\SendSMS.php on line 45 Fatal error: Maximum...
0
9969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11203
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10794
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9612
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7999
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7151
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5830
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6029
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4650
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.