I am trying to make a post via a PHP CURL request from an external application; however, the post data is not being delivered to the EE template. It works when I just use a simple html form post; however, with curl…the post variable is null! How can I fix this?
In my template page I have this code:
$something = $this->EE->input->post(“something”);
//the something code is returning null
echo $something;
The php curl code is shown below:
$url = ‘http://localhost/training/api/get-content2’;
$url = ‘http://localhost/training/api/get-content2’;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Accept: application/json’, ‘Content-Type: application/json’));
//$data = array(‘something’ => urlencode(‘foofoofoo’));
curl_setopt($ch, CURLOPT_POSTFIELDS, ‘something=something’);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt( $curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$output = stripslashes($output);
$output = str_replace(’{if logged_in}’, ‘’, $output);
$output = json_decode($output, true);