Re: CURL receiving content data
| From: | Brian Rue | Date: | Fri, 24 Aug 2007 08:36:58 +0000 |
| Subject: | Re: CURL receiving content data | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-261222@lists.php.net to get a copy of this message | ||
Bruce, I tried using curl to just get the feed and it worked ok:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
'http://api.beta.blogs.aol.com/bsteinback0224/service.xml');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
print curl_exec($ch);
My guess would be that one or more of the extra headers you're sending are
causing the server to get confused... i.e. maybe you're missing a slash in
the referer, or you're otherwise not sending the exact headers the server is
expecting. The Live HTTP Headers firefox extension has been really helpful
for me; give it a try if you haven't already.
Good luck...
-Brian Rue
Bruce Steinback wrote:
> Hi all,
>
> First thanks to the people that corrected my dumb mistake on XML parsing a
> few weeks ago, and let's hope that this is as dumb.
>
> I've got a mashup that when contacted attempts to gather feed info to mash
> into it's response. I send a GET request (Atom request to be exact), and
> get the following back:
>
> HTTP/1.0 200 OK Date: Thu 23 Aug 2007 21:27:48 GMT Server: Apache/2.0.54
> (Unix) mod_ssl/2.0.54 OpenSSL/0.9.7e mod_jk/1.2.14 Content-Length: 222
> Connection: close Content-Type: application/atomsvc+xml;charset=UTF-8
>
> but no Content data (the Atom XML response in the Content-Type).
>
> Here's my code:
> $checkBlogsUrl = "http://api.beta.blogs.aol.com/"
> . $owner .
> "/service.xml"; $sessionRequest = curl_init();
> curl_setopt( $sessionRequest, CURLOPT_URL, $checkBlogsUrl);
> curl_setopt( $sessionRequest, CURLOPT_RETURNTRANSFER, true );
> curl_setopt( $sessionRequest, CURLOPT_REFERER, $baseUrl .
> "loginresp-blogs.php"); $header[] = "X-AOL-DEVID: " . $devId;
> $header[] = "Authorization=OpenAuth token: " . $token;
> curl_setopt( $sessionRequest, CURLOPT_HTTPHEADER, $header);
> curl_setopt( $sessionRequest, CURLOPT_HEADER, 1);
> $responseBase = curl_exec( $sessionRequest );
> // $responseXml = curl_multi_getcontent($sessionRequest);
> print "<br/>" . $responseBase;
>
> As you can see, I tried curl_multi_content hoping it might be for like
> multiple content, but in reviewing the spec, it's obviously for
> aggregating multiple requests.
>
> There's definitely content there, you can try:
> http://api.beta.blogs.aol.com/bsteinback0224/service.xml
> to see it. And the Content-Length figure looks about right (it was 847
> for bsteinback0224, which was pretty close to the file size when I saved
> it).
>
> I can find dozens of examples of adding POST Content, but none for reading
> file content. Please don't tell me it can't be done :-(
>
> Thanks,
> Bruce
>
>
>
>
>
>
____________________________________________________________________________________
> Pinpoint customers who are looking for what you sell.
> http://searchmarketing.yahoo.com/