Jump to content

cURL Post


The Little Guy

Recommended Posts

I am doing this:

$fields = array(
"code" => $this->code,
"secret" => $this->secret,
"domain" => $_SERVER['HTTP_HOST'],
);
$this->ch = curl_init();
curl_setopt($this->ch, CURLOPT_URL, "http://weblyize.com/API/v1");
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($this->ch, CURLOPT_POST, true);
$opt = curl_exec($this->ch);
return $opt;

 

But the post fields are not being passed for some reason, and I can't figure out why. I do a print_r($_POST); on the url above, and it is empty.

 

Do you see anything wrong with my curl?

 

Here is the page:

http://phpsnips.com/search/doSearch.php

Link to comment
https://forums.phpfreaks.com/topic/251391-curl-post/
Share on other sites

It's hard to say that it's not an issue on their side, because we can't test it.

 

<?php

$post = array(
'Comments'=>'Testing!',
'hidden field'=>'lalalala'
);

$site = 'http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi';

$session = curl_init();
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session, CURLOPT_URL, $site);
curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($session);

print_r($response);

curl_close($session);

?>

 

works.

Link to comment
https://forums.phpfreaks.com/topic/251391-curl-post/#findComment-1289364
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.