简体   繁体   中英

Twilio get recording from call object

I want to get the recording (URI) from the call object (JSON), these are all the calls on the account:

$this->log = $this->client->calls->read();

I am looping through them like:

foreach($this->log as $call) {
    echo $call->duration;
}

Output 5, 10 ect. If I change duration to recordings it doesn't work, why?

The docs are so useless, it doesn't say anything about this.. I can see the Recordings URI in the object but I dont know how to access it the "Twilio" way. (or any other way..)

https://www.twilio.com/docs/api/rest/call#instance-subresources-recordings

Twilio developer evangelist here.

Recordings isn't a property on a Call , they are a subresource. So, you need to make another call to the API. So, to get the Recordings you'd need to do the following:

foreach($this->log as $call) {
    foreach($call->recordings->read() as $recording) {
      echo $recording->uri;
   }
}

Sorry about your experience with the documentation. I will feed this back to the team so that we can hopefully improve this for the future.

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