cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

curl not downloading proper file

From: Kajetan Krykwiński <kajetan.krykwinski_at_gmail.com>
Date: Fri, 13 Aug 2010 00:43:39 +0200

I want to download XML file, e.g
http://wojtek1992u.wrzuta.pl/xml/plik/0gn8Pwxjydv/nirvana_-_smells_like_teen_spirit.
When I use curl for Windows, everything's going right (curl - G
<address>). But if I'm trying to do the same, I've got other response (like
that: http://wojtek1992u.wrzuta.pl/xml/plik/0gn8Pwxjy - error - file not
found). This is PHP code i'm using:

<?php
$curl = curl_init('
http://wojtek1992u.wrzuta.pl/xml/plik/0gn8Pwxjydv/nirvana_-_smells_like_teen_spirit'<http://wojtek1992u.wrzuta.pl/xml/plik/0gn8Pwxjydv/nirvana_-_smells_like_teen_spirit%27>
);

curl_setopt($curl, CURLOPT_HEADERFUNCTION, 'dbg_curl_data');
curl_setopt($curl, CURLOPT_WRITEFUNCTION, 'dbg_curl_data');
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
curl_setopt($curl, CURLOPT_USERAGENT, 'curl/7.21.0 (i386-pc-win32)
libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.5 libidn/1.18 libssh2/1.2.6');

curl_exec($curl);

echo '<fieldset><legend>request headers</legend>
  <pre>', htmlspecialchars(curl_getinfo($curl, CURLINFO_HEADER_OUT)),
'</pre>
</fieldset>';

echo '<fieldset><legend>response</legend>
  <pre>', htmlspecialchars(dbg_curl_data(null)), '</pre>
</fieldset>';

function dbg_curl_data($curl, $data=null) {
  static $buffer = '';

  if ( is_null($curl) ) {
    $r = $buffer;
    $buffer = '';
    return $r;
  }
  else {
    $buffer .= $data;
    return strlen($data);
  }
}

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2010-08-13