AWS Lambda — Invoke by straight PHP curl

Sandesh B Suvarna
Feb 25, 2017 · 1 min read

$data = array(‘key’=>’key1');
$data_string = json_encode($data);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,”ENTER_YOUR_PUBLIC_URL");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Content-Type: application/json’,
‘Content-Length: ‘ . strlen($data_string))
);

$result = curl_exec($ch);

Sandesh B Suvarna

Written by

Co-Founder @ 4Five labs Inc, Ex-IBMer, Covered on CNET.com for “Building $1.4 Million worth app within 4 Minutes”.