Try:
$result = curl_exec($cURL);
$result = json_decode($result,true);
Now you can access MessageID
from $result['MessageID']
.
As for the database, it's simply using a query like so:
INSERT INTO `tableName`(`Cancelled`,`Queued`,`SMSError`,`SMSIncommingMessage`,`Sent`,`SentDateTime`) VALUES('?','?','?','?','?');
Prepared.