Garethp / php-ews

PHP Exchange Web Services
BSD 3-Clause "New" or "Revised" License
112 stars 45 forks source link

How to get medias appointment #253

Open JGalbois opened 1 year ago

JGalbois commented 1 year ago

Hi

I am trying to retrieve the media attached to an appointment

    $calendar = $ews->ews->getCalendar();
    $oEventDetail = $calendar->getCalendarItem($ExchangeId, $ChangeKey);
    $attachments = $oEventDetail->getAttachments();

I see clearly 1 media

    tFileAttachment : Array
    (
        [0] => garethp\ews\API\Type\FileAttachmentType Object
            (
                [isContactPhoto] => 
                [content] => 
                [attachmentId] => garethp\ews\API\Type\AttachmentIdType Object
                    (
                        [rootItemId] => 
                        [rootItemChangeKey] => 
                        [id] => AAMkADZhNGEwMDM0LTUyYzQtNDY1Ni05YzhjLTk2NWY1NmY4OTA2MABGAAAAAADdQnAC3NjZSoBxMzH8bQlpBwAN5TKg81M8QL8H2m8inmvJAAAE8fPWAAAN5TKg81M8QL8H2m8inmvJAAB4IQvCAAABEgAQABIuYtzxgExAvD23NKSxL8s=
                        [_] => 
                        [_value] => 
                        [_typeMap] => Array
                            (
                            )

                    )

                [name] => titres.PNG
                [contentType] => image/png
                [contentId] => 
                [contentLocation] => 
                [size] => 1889
                [lastModifiedTime] => 2023-07-31T13:10:36
                [_typeMap] => Array
                    (
                        [lastModifiedTime] => dateTime
                    )

                [isInline] => 
                [_] => 
                [_value] => 
            )

    )

I see the media key clearly $tFileAttachment[0]->getAttachmentId();

Here is my trace

garethp\ews\API\Type\AttachmentIdType Object
    (
        [rootItemId] => 
        [rootItemChangeKey] => 
        [id] => AAMkADZhNGEwMDM0LTUyYzQtNDY1Ni05YzhjLTk2NWY1NmY4OTA2MABGAAAAAADdQnAC3NjZSoBxMzH8bQlpBwAN5TKg81M8QL8H2m8inmvJAAAE8fPWAAAN5TKg81M8QL8H2m8inmvJAAB4IQvCAAABEgAQABIuYtzxgExAvD23NKSxL8s=
        [_] => 
        [_value] => 
        [_typeMap] => Array
            (
            )

    )

But when I try to retrieve the content, I get an error

    $calendar->getAttachment($tFileAttachment[0]->getAttachmentId());
    >> Fatal error: Uncaught Error: Call to undefined method garethp\ews\CalendarAPI::getAttachment()

Do you have an idea how to do this?

Thank's