Reply to posting with cURL problem

Your name:

Reply:


Posted by zorro on 12/28/06 17:40

Hello there,

I can't figure out why is it that when i use an array for my postfields
it doesn't work :

this works
curl_setopt($curl, CURLOPT_POSTFIELDS, "clown=bozo" );

this doesn't
curl_setopt($curl, CURLOPT_POSTFIELDS, array('clown'=>'bozo') );


The web site i post to only responds when my parameters are in a
string, but it sends nothing back when i use an array - no headers, no
error, nothing. And cURL shows no error either. So there must be
something different in the way cURL posts from an array. It's like the
web site reads it differently than when i post a string and possibly
some error is generated on the server. I make other posts to the same
web site and all is okay except when i use an array. Any ideas what
might be going on?

Here is the full code

$curl = curl_init();

curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookiejar.txt' );
curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookiejar.txt' );
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows
NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_MAXREDIRS, 2);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, array('clown'=>'bozo') );

curl_setopt($curl, CURLOPT_URL, 'http://www.somesite.com/form.htm');
$response = curl_exec($curl);

echo $response; // this echos nothing and when saved to a file the
file is 0 bytes...

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация