473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

fsockopen

hi i am struggling with this... maybe someone else had a similar problem
before...

i have to pass 2 variables: (language) and an (xml query string) using http
POST to a search engine. doing this with a normal html form, the seach
engine returns a nice xml response. yet, when passing the POST vars using
the script below, the server does not give any response, it keeps loading
the page.
the script for posting the variables does work since i tested it, i just
dont know what to look for anymore...

html form:
<form name=SeekEngine method=Post
action="http://www.suedtirol.info/XmlApi/Demo/SeekEngine.get?xx=1">
<input type=hidden name=Language value=IT>
<textarea style="font-size:12px" name="XmlParameters" value="" rows=10
cols=135>
<Parameters>
<Group Value="Bike" />
<HotelComfort Value="A.001.004.000.000;A.001.003.000.000;" />
<HotelComfort Value="A.012.020.015.000;A.012.020.020.000;" />
<Stay CheckIn="12/1/2003" Days="2" Board="4" Bookable="0" />
<Room Qty="1" Persons="2" Type="1" />
<HierarchyID Value=""/>
</Parameters>
</textarea>
<input type=button onclick="SendData(form);" name=sEEKeNGINE
value="Engine.Get">
</form>

php fct:

<?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($datastream, $url)
//################################################## ########################
#######################
{
//replace http:// with the empty string, get host, get resource
$url = preg_replace("@^http://@i", "", $url);
$host = substr($url, 0, strpos($url, "/"));
$uri = strstr($url, "/"); // kontakt/formular.php

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

//construct post request to be sent to server, include size of reqbody
$contentlength = strlen($reqbody);
$reqheader = "POST $uri HTTP/1.1 \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($host, 80, $errno, $errstr);
if (!$socket)
{
$result["errno"] = $errno;
$result["errstr"] = $errstr;
return $result;
}
fputs($socket, $reqheader);
while (!feof($socket))
{
$result[] = fgets($socket, 4096);
}
fclose($socket);
return $result;
}
//################################################## ########################
#######################
?>

any help is very appreciated : )
tom
Jul 17 '05 #1
1 2467
thomas werth <we***@cyber-ideas.com> wrote:
hi i am struggling with this... maybe someone else had a similar problem
before... i have to pass 2 variables: (language) and an (xml query string) using http
POST to a search engine. doing this with a normal html form, the seach <input type=button onclick="SendData(form);" name=sEEKeNGINE
value="Engine.Get">


Offtopic, but I'm guessing the page "refreshes" because you're
not passing the sEEKeNGINE value when you POST.

--
niall

Jul 17 '05 #2

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

Similar topics

2
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...
2
by: Loopy | last post by:
I'm trying to write a script that will connect to an external site so that I can get access referer information in a database on another one of my sites. I got errors, so I tried to write a script...
9
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'); ?>
6
by: murd | last post by:
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...
1
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...
8
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 =...
4
by: keychain | last post by:
I'm experience the infamous "SSL: Fatal Protocol Error" bug with Apache 2.x According the fopen() documentation: "If you are using fsockopen() to create an ssl:// socket, you are responsible...
6
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...
0
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...
5
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.