-1

I am using Twilio PHP library.

I would like to get the total count of messages available in an account.

I use the following code:

$client = new Services_Twilio($AccountSid, $AuthToken); 
$messages = $client->account->messages ;
echo count($messages);

The count always displays as one (1). Let me know how to get the total count.

Thanks.

Pierre Maoui
  • 5,976
  • 2
  • 27
  • 28
arun kumar
  • 703
  • 2
  • 13
  • 33

1 Answers1

1

Twilio evangelist here.

I'd suggest using a Usage Record to get this information:

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "ACed732a3c49700934481addd5ce1659f0"; 
$token = "{{ auth_token }}"; 
$client = new Services_Twilio($sid, $token);

// Loop over the list of records and echo a property for each one
$callRecord = $client->account->usage_records->getCategory('sms');
echo $callRecord->usage;

Hope that helps.

Devin Rader
  • 10,260
  • 1
  • 20
  • 32
  • Thanks for your answer. Let me explain my requirement in detail. I am creating a log report of messages received / sent. I have pagination system for the report. I need to know the total count of messages for pagination. To get the total calls the documentation says, we can use $calls = $client->account->calls; echo count($calls); I am looking at similar solution. – arun kumar Jun 19 '15 at 14:34