Hi Brendan.
I tried running your code and the slightly modified version below worked for me from my local machine. I get the same xml with this code as when I load the url in my browser. I just created a file with this code and then ran if from the command line. My output is also included below. Hope that helps.

Cheers
Toro

The code:
--------
<?php
$theurl = "http://121.98.150.62:5574/MENU.XML";;

$ch = curl_init();
//curl_setopt( $ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip"));

curl_setopt($ch, CURLOPT_URL, $theurl );
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

//curl_setopt($ch, CURLOPT_PORT, $_SERVER['SERVER_PORT']);
//echo "SERVER PORT: ".$_SERVER['SERVER_PORT'];
//curl_setopt($ch, CURLOPT_HTTPHEADER,array('Expect:'));

$xmlresponse = curl_exec($ch );
echo curl_error($ch);
echo $xmlresponse;curl_close($ch);


The output:
-----------
t...@moutere:~$ php curl.php | head -n 20
HTTP/1.1 200 OK
Connection: close
Content-Type: application/xml
Content-Length: 152045
Expires: Fri, 20 Aug 2010 11:23:00 GMT
Server: Indy/10.1.5
Last-Modified: Fri, 20 Aug 2010 11:22:59 GMT

<?xml version="1.0" encoding="UTF-8"?>
<menu>
  <itemgroups>
    <itemgroup id="11">
      <name>Coffee</name>
      <forb>B</forb>
    </itemgroup>
    <itemgroup id="14">
      <name>Beverages</name>
      <forb>B</forb>
    </itemgroup>
    <itemgroup id="15">



On 20/08/10 23:15, Brendan Brink wrote:
Hi there all,

this is the code i currently have:

                        $theurl = "http://121.98.150.62:5574/MENU.XML";;
                        
                        $ch = curl_init();
                        //curl_setopt( $ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: 
$ip",
"HTTP_X_FORWARDED_FOR: $ip"));

                        curl_setopt($ch, CURLOPT_URL, $theurl );
                        curl_setopt($ch, CURLOPT_HEADER, 1);
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
                        curl_setopt($ch, CURLOPT_PORT, $_SERVER['SERVER_PORT']);
                        echo "SERVER PORT: ".$_SERVER['SERVER_PORT'];
                        //curl_setopt($ch, CURLOPT_HTTPHEADER,array('Expect:'));
                        $xmlresponse = curl_exec($ch );
                        echo curl_error($ch);
                        echo $xmlresponse;curl_close($ch);
                        
can anyone see any errors as to why curl is not getting the xml from the url?

On Fri, Aug 20, 2010 at 11:10 PM, Brendan Brink
<[email protected]>  wrote:
hi there,

i did not get Bruce's latest suggestion? thought he got mixed up
thinking he was on the LINUX list...

On Fri, Aug 20, 2010 at 11:02 PM, Jochen Daum<[email protected]>  wrote:
Hi Brendan,
On Fri, Aug 20, 2010 at 10:47 PM, Brendan Brink<[email protected]>
wrote:

hi there again,

have not been able to go to the host PC to change the file, but been
thinking about it and not sure you are on the same page as I am
regarding this.

the script i am writing is on my server, and i am addressing a clients PC.

they are running a point of sale system which is addressed using that IP
number.

I need to address the client PC on the fly through my script using
CURL and obtain the XML.

I dont think the 'test' url will work if the script on my server is
trying to address the client's PC...

let me know if you understand what I am trying to do...

If you wanted to change the hosts file, you would have to do it on the
server - yes. But as I said I think there is little prospect in trying this
because it is likely not the problem. Have you tried Bruce's latest
suggestion? It looks much more promising.
HTH, Jochen


On Fri, Aug 20, 2010 at 9:27 PM, Jochen Daum<[email protected]>  wrote:
Hi Brendan,
On Fri, Aug 20, 2010 at 9:15 PM, Brendan Brink
<[email protected]>
wrote:

hi there Jochen,

So from what you say below...

I need to update the hosts file on the PC at the IP address to set the
IP address to a line of text...

and then I can curl the line of text as I would a normal URL from my
script?

Well, maybe do the hosts file change just to check it is not the problem
- I
highly doubt it. Your url with the port would look like this (its really
search and replace your IP address):
http://test:5574/Invoice?txtcode=R5W2


What about the PORT number would it work ok?

The IP address is the address of my customers POS system, I need to
CURL it to obtain the XML from my website script.


Really the problem is that the server looks at one of your browser
headers
that is missing and doesn't return the request. So you need to figure
out
how to add custom headers to your curl request and see if that fixes the
problem.
Keep us posted.


Sorry if my query seems ignorant, but I am not familiar with the
technologies you are talking about.

No worries, just take it step by step.
HTH, Jochen

--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

--
Kind Regards,

Brendan Brink

SMS Marketing Consultant | Manager
Sell2Cell Ltd.

021 0246 1646 | [email protected] | www.sell2cell.co.nz




   We provide customized, cost-effective SMS&  Web Solutions
   Need a website? Need to integrate text-messaging into your business
   or website? Contact us today for a free no-obligation quote!

   VISIT OUR ASSOCIATED WEBSITES:   textvouchers.com | textguru.co.nz

WARNING This email contains information which is CONFIDENTIAL and may
be subject to LEGAL PRIVILEGE. If you are not the intended recipient,
you must not peruse, use, disseminate, distribute or copy the email or
attachments. If you have received this in error, please notify us
immediately by return email, facsimile, or telephone (call us
collect).

--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

--
Kind Regards,

Brendan Brink

SMS Marketing Consultant | Manager
Sell2Cell Ltd.

021 0246 1646 | [email protected] | www.sell2cell.co.nz




   We provide customized, cost-effective SMS&  Web Solutions
   Need a website? Need to integrate text-messaging into your business
   or website? Contact us today for a free no-obligation quote!

   VISIT OUR ASSOCIATED WEBSITES:   textvouchers.com | textguru.co.nz

WARNING This email contains information which is CONFIDENTIAL and may
be subject to LEGAL PRIVILEGE. If you are not the intended recipient,
you must not peruse, use, disseminate, distribute or copy the email or
attachments. If you have received this in error, please notify us
immediately by return email, facsimile, or telephone (call us
collect).





--
http://karere.co.nz
http://accountaneer.com

--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

Reply via email to