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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.