简体   繁体   English

通过 php zimbra-api 在 Zimbra 中获取消息

[英]Get message in Zimbra by php zimbra-api

I use PHP Zimbra-API and try to get messages by search request.我使用PHP Zimbra-API并尝试通过搜索请求获取消息。 My request is我的要求是

$req = new \Zimbra\Mail\Request\Search();

$req->setQuery('Mail Delivery System in:inbox')
                ->setResultMode('IDS')
                ->setField('subject')
                ->setSearchTypes('message')
                ->setLimit(1000);

How can I get response?我怎样才能得到回应? I didn't find any method of Search like getRespone() or something else.我没有找到像 getRespone() 或其他东西这样的 Search 方法。 Or my request is incorrect?还是我的要求不正确?

The code编码

They recently added a doc section showing exactly your use case in docs/usage.md :他们最近在docs/usage.md中添加了一个文档部分,准确地显示了您的用例:

<?php declare(strict_types=1);

require_once 'vendor/autoload.php';

use Zimbra\Mail\MailApi;

$query = 'in:inbox';

$api = new MailApi('https://zimbra.server/service/soap');
$api->authByAccountName($accountName, $password);
$response = $api->search($query, FALSE, 'message');
$messages = $response->getMessageHits(); //$messages contains the results

The function function

The search() function used by the example and defined in src/Mail/MailApi.php has all the parameters needed for pagination and other stuff示例使用并在src/Mail/MailApi.php中定义的search() function 具有分页和其他内容所需的所有参数

public function search(
    ?string $query = NULL,
    ?bool $inDumpster = NULL,
    ?string $searchTypes = NULL,
    ?string $groupBy = NULL,
    ?int $calItemExpandStart = NULL,
    ?int $calItemExpandEnd = NULL,
    ?bool $quick = NULL,
    ?SearchSortBy $sortBy = NULL,
    ?bool $includeTagDeleted = NULL,
    ?bool $includeTagMuted = NULL,
    ?string $taskStatus = NULL,
    ?string $fetch = NULL,
    ?bool $markRead = NULL,
    ?int $maxInlinedLength = NULL,
    ?bool $wantHtml = NULL,
    ?bool $needCanExpand = NULL,
    ?bool $neuterImages = NULL,
    ?WantRecipsSetting $wantRecipients = NULL,
    ?bool $prefetch = NULL,
    ?string $resultMode = NULL,
    ?bool $fullConversation = NULL,
    ?string $field = NULL,
    ?int $limit = NULL,
    ?int $offset = NULL,
    array $headers = [],
    ?CalTZInfo $calTz = NULL,
    ?string $locale = NULL,
    ?CursorInfo $cursor = NULL,
    ?MsgContent $wantContent = NULL,
    ?bool $includeMemberOf = NULL,
    ?bool $warmup = NULL
): ?Message\SearchResponse

Query Syntax查询语法

Regarding the query syntax please refer to the official Zimbra documentation关于查询语法请参考Zimbra 官方文档

The "Search Language Structure" described is a common standard between webmail usage, Rest API and Soap API (the one used by this library)描述的“搜索语言结构”是 webmail 使用之间的通用标准,Rest API 和 Soap ZDB97AZ7the one by this library)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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