Twilio developer evangelist here.
If you check the output for the first code sample on the documentation page for sending messages with Twilio then you will see that the returned JSON should have a sid
property. Like this:
{
"sid": "MMc781610ec0b3400c9e0cab8e757da937",
"date_created": "Mon, 19 Oct 2015 07:07:03 +0000",
"date_updated": "Mon, 19 Oct 2015 07:07:03 +0000",
"date_sent": null,
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"to": "+15558675309",
"from": "+15017250604",
"body": "This is the ship that made the Kessel Run in fourteen parsecs?",
"status": "queued",
"num_segments": "1",
"num_media": "1",
"direction": "outbound-api",
"api_version": "2010-04-01",
"price": null,
"price_unit": "USD",
"error_code": null,
"error_message": null,
"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MMc781610ec0b3400c9e0cab8e757da937.json",
"subresource_uris": {
"media": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/MMc781610ec0b3400c9e0cab8e757da937/Media.json"
}
}
I just used similar code to you (I didn't send a media URL) and could echo $result->sid
.
$result = $client->account->messages->create(
'MY_NUMBER',
array(
'from' => 'MY_TWILIO_NUMBER',
'body' => "Hey Jenny! Good luck on the bar exam!"
)
);
echo $result->sid;
Let me know if that helps.