Hi All,
I'm fairly new to php. I am working on a project where I am building some php pages for a site that has an e-commerce off the shelf package (Kurant StoreSense).
I can access their proprietary DB by using an XML extension they wrote. I have to do this by sending the xml file via POST over HTTP. I am really struggling with this.
I was able to find this function:
<?
/ sendToHost
* Params:
* $host - Just the hostname. No [url]http://[/url] or
/path/to/file.html portions
* $method - get or post, case-insensitive
* $path - The /path/to/file.html part
* $data - The query string, without initial question mark
* $useragent - If true, 'MSIE' will be sent as
the User-Agent (optional)
*
* Examples:
* sendToHost('www.google.com','get','/search','q=php_imlib');
* sendToHost('www.example.com','post','/some_script.cgi',
* 'param=First+Param&second=Second+param');
*/
function sendToHost($host,$method,$path,$data,$useragent=0)
{
// Supply a default method of GET if the one passed was empty
if (empty($method))
$method = 'GET';
$method = strtoupper($method);
$fp = fsockopen($host,80);
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
if ($useragent)
fputs($fp, "User-Agent: MSIE\n");
fputs($fp, "Connection: close\n\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
return $buf;
}
?>
--------------------------------------------------------
But I am not sure if this is what I need and I am confused how to use it.
I have this XML file:
-----------------
<?xml version="1.0"?>
<XTE version="2.0" locale="en_US">
<Client>
<Version>1.2</Version>
</Client>
<Logon>
<Zone>store</Zone>
<!-- enter valid logon information -->
<UserName></UserName>
<Password></Password>
<ShortName></ShortName>
</Logon>
<Request type="Product" txnid="pm01">
<Action>Query</Action>
<Query>
<Select>
<ProductName/>
<ProductNo/>
<Description/>
</Select>
</Query>
</Request>
</XTE>
----------------------------------
THis will give me all the product in the DB, which is what i need. This file is products.xml. In order for this to work I have to send it to
[url]http://ip_address/xte/storesense/Process.bok[/url]
How would I do this with the function above? Or is this not the right thing I need? Will this function allow me to get the data returned?
Thanks
Tom