1
votes

I am creating an application in PHP and I wanted to integrate Twilio API for sending SMS. I want to handle just the outbound messages. I am using the official Twilio-PHP wrapper library.

    require_once "Twilio.php";    

    $accountSid = "<<test-sid>>";
    $authToken= "<<test-auth-token>>";
    $fromNumber = "+15005550006";

    $client = new Services_Twilio($accountSid, $authToken);  

    $messages = $client->account->sms_messages->getIterator(0, 50, 
                                      array('DateSent>=' => '2013-01-01',
                                            'DateSent<=' => '2013-09-31',
                                            'From' => $fromNumber));
    foreach($messages as $message){
        echo $message->body;
    }

The above code is the core idea of the code that I use in my application. When I run the application, I get the below exception message.

    Resource not yet accessible with Test Account credentials

When I use the live account Sid and Auth token with the phone number, it works fine. But I want to test my script with the test credentials. I got the test Sid and auth token from the link https://www.twilio.com/user/account/developer-tools/test-credentials and using the magic number +15005550006 as the "from" phone number. I don't want to be charged during my testing.

Please let me know if I am missing anything in the account setup.

Also I am not sure how to handle this exception and show a user-friendly message.

1

1 Answers

2
votes

The test credentials are designed to be used in situations where using the live credentials would cost you money - sending an SMS, making a call, purchasing a phone number. They don't cover the entire Twilio API (yet).

If you are only listing your messages, you should be able to do so safely with the live credentials, as retrieving messages does not cost anything. (Or am I missing a part of your question)?