PHP cURL POST request

Script for submiting records to a remote server withour user interfere

Page 1 of 1

5 Replies - 902 Views - Last Post: 15 September 2009 - 01:33 PM Rate Topic: -----

#1 mrdunkeriz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 03-September 09

PHP cURL POST request

Post icon  Posted 09 September 2009 - 06:26 AM

Hello everybody,

I'm trying to set up a script, that allows me to publish ads at different websites without user interference. I'm using PHP cURL and the script is working fine on localhost. However, it does nothing on
http://www.nsl.lt/?v...amp;subcatid=82

This is a Lithuanian advertising website. The form has 3 parameters - you'll find them in the code. The script works without error/warning, but the post is obviously not done. You would be able to see it at http://www.nsl.lt/1n.../82-tinklapiai/


// Parameters to be sent
$url = 'http://www.nsl.lt/index.php?view=post&cityid=1&lang=en&catid=12&subcatid=82&adid=0&imgid=0&countryid=0&areaid=0&pos=0&picid=0&page=0&foptid=0&eoptid=0&pricemin=0&pricemax=0&';
$curlPost = 'adtitle=' .urlencode('Title').
			'&addesc=' .urlencode('Aprasymas').
			'&agree=' .urlencode('1');

// cURL

$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $curlPost);
curl_exec ($c);

// Three lines below for debugging
print_r(curl_getinfo($c)); 
echo "\n\ncURL error number:" .curl_errno($c); 
echo "\n\ncURL error:" . curl_error($c); 

curl_close ($c);




Does anybody had any previous experience on cURl. Any kind of help will be highly appreciated!

Is This A Good Question/Topic? 0
  • +

Replies To: PHP cURL POST request

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,224
  • Joined: 23-August 08

Re: PHP cURL POST request

Posted 09 September 2009 - 09:02 AM

That form's method is GET, rather than POST:
<form action="?" method="get">

That could be it?
Was This Post Helpful? 0
  • +
  • -

#3 mrdunkeriz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 03-September 09

Re: PHP cURL POST request

Posted 10 September 2009 - 06:38 AM

That's another form, I'm working on. Sorry, I didn't mentione that before. I'm working with the main, BIG form, not with the one at the top of the page. Thanks for taking a look. Any more suggestions?
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,224
  • Joined: 23-August 08

Re: PHP cURL POST request

Posted 10 September 2009 - 07:48 AM

Ah, I see, sorry about that.

Is it maybe the hidden POST fields here?
<input name="subcatid" type="hidden" id="subcatid" value="82">
<input name="do" type="hidden" id="do" value="post">
<input name="galune" type="hidden" id="galune" value=".html">


Was This Post Helpful? 1
  • +
  • -

#5 mrdunkeriz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 03-September 09

Re: PHP cURL POST request

Posted 10 September 2009 - 02:38 PM

That could be it, I'll give it a try!
Was This Post Helpful? 0
  • +
  • -

#6 mrdunkeriz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 03-September 09

Re: PHP cURL POST request

Posted 15 September 2009 - 01:33 PM

Thanks a lot, JackOfAllTrades! The hidden fields - that was the problem! :))
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1