简体   繁体   中英

Fetch incoming call logs in twilio account

Basically i am fetching all call logs of my twilio account. I am using the below code:

$client = new Services_Twilio($sid, $token, $version);
foreach ($client->account->calls as $call) {
echo "Call from $call->from to $call->to at $call->start_time of length $call->duration";
}

it will give the all call records whose direction is outbound dial means it is giving call logs of outgoing calls but it is not giving me incoming call logs. So anybody tell me where Ia am wrong?

Twilio Developer Evangelist here.

You should be able to access calls in both directions by looping over the calls resource. Here is an example that shows the direction of each call you're looping over.

$client = new Services_Twilio($sid, $token, $version);
foreach ($client->account->calls as $call) {
    echo $call->direction;
}

It's possible you may want to actually loop using an iterator. This gives you two main benefits. First, you're able to filter your results. This will allow you to do things like retrieve calls to or from a specific number. You can read a bit more about filtering options in our docs . Second, you're able to paginate your results. This is a quick example filtering for calls that have happened since January 1st, 2014.

$client = new Services_Twilio($sid, $token, $version);
foreach ($client->account->calls->getIterator(0, 50, array(
    "StartTime>" => "2014-01-01"
    )) as $call
) {
    echo $call->direction;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM