Reputation: 5482
I am trying to use Twilio in my Laravel project, I have used it's aloha package. It works fine when I try to send messages or to create calls, but when I try to retrieve the call logs then it throw an exception.
Here is what I have tried so far:
$AccountSid = <ACCOUNT ID>;
$AuthToken = <AUTH TOKEN>;
$client = new \Services_Twilio($AccountSid, $AuthToken);
When I try to send message it works:
try{
$sms_content="";
$sms_content .="Amy has requested a quote for her wedding."."\n\n";
$sms_content .="";
$sms = $client->account->messages->sendMessage(
<FROM NUMBER>,
<TO NUMBER>,
$sms_content
);
}
catch (Exception $e) {
}
It also works when I try to create a call:
try {
// Initiate a new outbound call
$call = $client->account->calls->create(
// to call.
<FROM NUMBER>,
<TO NUMBER>,
array("url" => "http://demo.twilio.com/welcome/voice/")
);
echo "Started call: " . $call->sid;
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
but when I try to read a call it throws an error:
try {
// Get Recent Calls
foreach ($client->account->calls->read() as $call) {
$time = $call->startTime->format("Y-m-d H:i:s");
echo "Call from $call->from to $call->to at $time of length $call->duration \n";
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
The error I get is:
Call to undefined method Services_Twilio_Rest_Calls::read()
Upvotes: 0
Views: 216
Reputation: 27503
change this line
$client->account->calls->read()
to
$client->account->calls
Upvotes: 2