Re: CURL vs stream_socket_client

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Todd,
First off.. thanks for the reply.

I've dumped the xml data and tried to view it in Firefox... commented out
the curl code (and all the other stuff) just to see what exactly was getting
passed.

Firefox did not display it as it does xml... like when I got directly to
that xml file with firefox, I get the "This XML file does not appear to have
any style information associated with it. The document tree is shown below."
(grey bar)... it always shows properly formed xml documents like that for me
(collapsible)...

But, when I dump it in the PHP script using:
print $eparcelRequest;

It will just display the values... don't see any collapsible xml tags like
when I view the xml directly.
So I was thinking it might be in the format sent..

I'll try to set the user agent.

Thanks!
Yves Arsenault

"Love is the only force capable of transforming an enemy into a friend".
--Martin Luther King, Jr.


On Fri, Jan 30, 2009 at 12:19 PM, Boyd, Todd M. <tmboyd1@xxxxxxxx> wrote:

> > -----Original Message-----
> > From: Yves Arsenault [mailto:yves.arsenault@xxxxxxxxx]
> > Sent: Friday, January 30, 2009 9:40 AM
> > To: PHP List
> > Subject:  CURL vs stream_socket_client
> >
> > Hi there,
> > I'm not in PHP on a daily basis, but from time to time I get to
> program
> > a
> > little in PHP for certain projects.
> >
> > Recently, I've installed a Magento system... and I've installed a
> > canada
> > post shipping module for this system.
> >
> > One thing that seems to be tripping it up is that it's using curl.
> >
> > curl is attempting to send xml data to canada post's server on port
> > 30000.
> > The response from canada post's system is always an html page...
> >
> > I've run a test using stream_socket_client and have gotten it to work,
> > the
> > canada post's system responds with the corresponding XML data with
> > shipping
> > info.
> >
> > I'm wondering if there are any curlopt_ options that should be set
> that
> > aren't currently set...
> > Could be that curl is not sending properly formatted XML.
>
> This may be a stretch, but try to set the User Agent string to mimic
> Firefox before sending your request. I wrote a PHP scrape to gather
> guild member information from the World Of Warcraft Armory [1] a few
> years back, and it kept giving me HTML instead of XML until I used the
> User Agent of a browser that most sites accept is capable of parsing
> XML.
>
> A lot of sites conditionally send IE (and unknown browsers) XHTML
> instead of XML if there is any transformation of data involved.
>
> Also--your comment "Could be that curl is not sending properly formatted
> XML" is possible. Have you looked at the resulting HTML that is sent to
> curl to make sure that it's not a server error message? If it's the
> results you were looking for (but in XHTML format instead of XML), I'll
> bet it's a User Agent thing.
>
> Just a thought...
>
>
> // Todd
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux