View Single Post
  #1 (permalink)  
Old 08-03-2007, 05:50 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Admin
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 440
iTrader: (0)
TeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to beholdTeraTask is a splendid one to behold
[SOLVED] cURL Error #18?

OK. Here's one: I have the following code:
PHP Code:
<?php
$content 
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><methodCall><methodName>metaWeblog.getCategories</methodName><params><param><value><string>1</string></value></param><param><value><string>{USERNAME}</string></value></param><param><value><string>{PASSWORD}</string></value></param></params></methodCall>";

$ch curl_init();
curl_setopt($chCURLOPT_POST,1);
curl_setopt($chCURLOPT_POSTFIELDSIZEstrlen($content));
curl_setopt($chCURLOPT_POSTFIELDS,$content);
curl_setopt($chCURLOPT_URL,'{URL}');
curl_setopt($chCURLOPT_SSL_VERIFYPEER0); // Don't stress about SSL validity
curl_setopt($chCURLOPT_RETURNTRANSFER,1);

$headers[] = "Authorization: BASIC ".base64_encode('{USERNAME}:{PASSWORD}');
$headers[] = 'Content-type: application/xml';
curl_setopt($chCURLOPT_HTTPHEADER$headers);
$result=curl_exec ($ch);
$curl_error curl_error($ch);
$curl_error_no curl_errno($ch);

if (
$curl_error_no 0) {
  
$curl_error curl_error($ch);
  
$curl_error_no curl_errno($ch);
  echo 
"cURL Error: (".$curl_error_no.") ".$curl_error;
} else {
  echo 
"Successfully retrieved: ".$result;
}
curl_close ($ch);
?>
Which works on most servers just fine to fetch the XML returned by WordPress for a category listing. On one server, though, I get this message:

cURL Error: (18) transfer closed with 1372 bytes remaining to read

I have searched and searched ( curl "transfer closed with" "bytes remaining to read" - Google Search ) and read and read and cannot find a hint as to what the hell is happening. Does anyone have a clue on this? If so, can you clue me in?

Thanks a ton in advance!!!!!

NOTE: You'd need to change {USERNAME}, {PASSWORD}, and {URL} to the appropriate values for testing. Due to confidentiality, I cannot release the URL where this is failing, but I can get server info if necessary.

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!