Ok, after a second look there are some more suspicious things. As already mentioned, your CURL
request uses GET
instead of POST
.
$options = array(
...
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $postData,
);
Another thing is that you are encoding the POST
data for your CURL
call to JSON
, but then you are trying to access it on the other side using $_POST
, however there won't be anything, POST
data would have to be key/value query string formatted in order to appear in $_POST
. You have to read php://input
instead, which may be what you were trying to do with
$data = $this->request->data('json_decode');
However you must use CakeRequest::input()
for that purpose, and of course you must then use the $data
variable instead of $_POST
$data = $this->request->input('json_decode');
$exchange->username = $data['username'];
$exchange->password = $data['password'];
....
$tempEmail = $exchange->getEmailContent(
$email->Id,
$email->ChangeKey,
TRUE,
$data['attachmentPath']
);
Also make double sure that your CURL
request looks like expected:
$options = array(
...
CURLOPT_POSTFIELDS => $postData,
CURLINFO_HEADER_OUT => true // supported as of PHP 5.1.3
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
echo '<pre>';
print_r($info);
echo '</pre>';