0
votes

I am trying to use Plivo sms using php SDK. I am able to send message correctly:

How can i get the Response as in the following link so that i can store it in my Database:

https://api-reference.plivo.com/latest/php/resources/message/the-message-object

Example Response:

{
  "error_code": "200",
  "from_number": "18552828641",
  "message_direction": "outbound",
  "message_state": "failed",
  "message_time": "2016-08-17 21:26:44+05:30",
  "message_type": "sms",
  "message_uuid": "85ce8068-6fab-4f0a-9dc7-d6c852cdde91",
  "resource_uri": "/v1/Account/{auth_id}/Message/85ce8068-6fab-4f0a-9dc7-d6c852cdde91/",
  "to_number": "19352326448",
  "total_amount": "0.00000",
  "total_rate": "0.00350",
  "units": 1
}

For example, I need to know message_state, total_rate etc.

var_dump($message); gives following results

object(Plivo\Resources\Message\MessageCreateResponse)#32 (2) 
    { ["messageUuid":protected]=> 
    array(1) { [0]=> string(36) "39006dc4-fe7a-11e7-b939-06755d68f0ca" } ["_message":"Plivo\Resources\ResponseUpdate":private]=> string(17) "message(s) queued" } 

I tried using $message->message_state but keep getting errors.

Unfortunately Plivo documentation and support is very poor.

1
What error are you getting? can you post output of var_dump($message);? - Ataur Rahman
@Ataur Rahman I have updated my original post with var_dump results - Pamela
I am not familiar with their api, but seems like $message->getMessage(); will give you message_state. I hope someone experienced will help you to get details. - Ataur Rahman
Poor documentation and lack of support from Plivo. Lack of examples for their new API version. Twilio API is far better. - Pamela

1 Answers

0
votes

Plivo Sales Engineer here.

The response that you're looking for is from a different API which can be found here - Retrieve a Message. This API returns details of a particular message which includes the Message State.

$client->messages->get($id) is the corresponding function in the new PHP SDK.

Let me know if this doesn't resolve your issues.