EWS CreateAttachment API调用无法正常工作

时间:2018-04-11 13:08:26

标签: php curl exchangewebservices

我目前在EWS 2010中遇到CreateAttachment API调用的一些问题。我们正在使用带有curl 5.5的PHP 7.49.1

我们目前正在使用以下小脚本来测试此问题:

$ewswrapper = new EWSWrapper($host, $user, $pass);

try {

    // See examples:
    //
    // http://jamesarmes.com/php-ews/doc/0.1/examples/contact-set-update-photo.html
    // https://github.com/jamesiarmes/php-ews/blob/master/examples/contact/set-photo.php

    $picture = base64_decode(" ... some valid base64 image ... ");

    $attachment = new EWSType_FileAttachmentType();
    $attachment->IsContactPhoto = true;
    $attachment->Content = $picture;
    $attachment->Name = "ContactPicture.jpg";
    $attachment->ContentType = "image/png";

    // Create the attachment request
    $attRequest = new EWSType_CreateAttachmentType();
    $attRequest->ParentItemId = new EWSType_ItemIdType();
    $attRequest->ParentItemId->Id = " ... some ItemId of a contact ... ";
    $attRequest->ParentItemId->ChangeKey = " ... some ChangeKey of the contact ... ";
    $attRequest->Attachments = new EWSType_NonEmptyArrayOfAttachmentsType();
    $attRequest->Attachments->FileAttachment = [];
    $attRequest->Attachments->FileAttachment[] = $attachment;

    $ewswrapper->service->CreateAttachment($attRequest);

} catch (Exception $e) {
    var_dump($e->getMessage());
}

响应的返回状态代码为100。据我们所知,答案是空的。在发送请求之前转储请求会向我们显示一个理论上应该有效的xml输出。我们检查了https://msdn.microsoft.com/en-us/library/office/aa565931(v=exchg.140).aspx上的官方Microsoft文档和http://jamesarmes.com/php-ews/doc/0.1/examples/contact-set-update-photo.html上的API示例。

对API的其他请求完美无缺。我们可以创建,更新,查询和删除就好了,似乎这个请求特别失败了。

我们非常感谢任何指向正确方向的指示!提前致谢!如果需要有关代码,基础设施等的更多信息,请询问!

0 个答案:

没有答案