exec($this->buildCurlCommand($url, $data, $headers));
protected function buildCurlCommand($url, $data, $headers)
{
// TODO(dcramer): support ca_cert
$cmd = $this->curl_path.' -X POST ';
foreach ($headers as $key => $value) {
$cmd .= '-H ' . escapeshellarg($key.': '.$value). ' ';
}
$cmd .= '-d ' . escapeshellarg($data) . ' ';
$cmd .= escapeshellarg($url) . ' ';
$cmd .= '-m 5 '; // 5 second timeout for the whole process (connect + send)
if (!$this->verify_ssl) {
$cmd .= '-k ';
}
$cmd .= '> /dev/null 2>&1 &'; // ensure exec returns immediately while curl runs in the background
return $cmd;
}