Zimbra PHP API!!

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Jhonmicky
Posts: 31
Joined: Tue Aug 06, 2019 7:38 pm

Zimbra PHP API!!

Postby Jhonmicky » Tue Nov 05, 2019 1:27 am

Using https://github.com/zimbra-api/zimbra-api/

Successfully querying and getting data back using the api just don't know how use the data being passed back... can someone post an example of how I should be using data passed back from the response.fedloan irs.gov easybib


User avatar
rcardozo1987
Posts: 23
Joined: Tue Sep 10, 2019 9:14 pm
ZCS/ZD Version: NETWORK edition, Patch 8.8.15_P11

Re: Zimbra PHP API!!

Postby rcardozo1987 » Tue Aug 18, 2020 12:16 pm

Jhonmicky wrote:Using https://github.com/zimbra-api/zimbra-api/

Successfully querying and getting data back using the api just don't know how use the data being passed back... can someone post an example of how I should be using data passed back from the response.fedloan irs.gov easybib


Jhonmicky, it seems you need some help with PHP... not Zimbra... right?
User avatar
barrydegraaff
Zimbra Employee
Zimbra Employee
Posts: 102
Joined: Tue Jun 17, 2014 3:31 am
Contact:

Re: Zimbra PHP API!!

Postby barrydegraaff » Thu Sep 03, 2020 7:40 am

After setting up the php soap as described in https://github.com/zimbra-api/zimbra-api/ it can be used like so:

Code: Select all

<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// This file is generated by Composer
require_once 'zimbra-api/vendor/autoload.php';

$api = \Zimbra\Admin\AdminFactory::instance('https://zimbra.EXAMPLE.COM:7071/service/admin/soap');
$api->auth('soapapi', 'YOUR ADMIN PASSWORD HERE');
$account = new \Zimbra\Struct\AccountSelector(\Zimbra\Enum\AccountBy::NAME(), 'soapapi');
$accountInfo = $api->getAccountInfo($account);

print_r($accountInfo);

phpinfo();
--
Barry de Graaff
Admin of Zimbra-Community Github: https://github.com/orgs/Zimbra-Community/
Developer of Zimbra OpenPGP Zimlet, Zimbra ownCloud Zimlet and more.
A Zetalliance Founder http://www.zetalliance.org/
dad1969
Posts: 2
Joined: Tue Sep 15, 2015 4:29 am

Re: Zimbra PHP API!!

Postby dad1969 » Wed Mar 03, 2021 6:06 am

And what if I want to get messages by search request? I try to find messages by subject "Mail Delivery System" in inbox folder:

Code: Select all

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

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

and get $req like

Code: Select all

Zimbra\Mail\Request\Search Object
(
    [_requestName:Zimbra\Soap\Request:private] => SearchRequest
    [_responseName:Zimbra\Soap\Request:private] => SearchResponse
    [_properties:Zimbra\Struct\Base:private] => PhpCollection\Map Object
        (
            [elements:protected] => Array
                (
                    [resultMode] => IDS
                    [field] => subject
                    [types] => message
                    [limit] => 1000
                )
        )
    [_children:Zimbra\Struct\Base:private] => PhpCollection\Map Object
        (
            [elements:protected] => Array
                (
                    [query] => Mail Delivery System in:inbox
                )
        )
    [_value:Zimbra\Struct\Base:private] =>
    [_xmlNamespace:Zimbra\Struct\Base:private] => urn:zimbraMail
    [listeners:protected] => Array
        (
            [before] => Array
                (
                    [0] => Closure Object
                        (
                            [this] => Zimbra\Mail\Request\Search Object
 *RECURSION*
                            [parameter] => Array
                                (
                                    [$sender] =>
                                )
                        )
                )
        )
    [_headers:Zimbra\Mail\Request\Search:private] => Zimbra\Common\TypedSequence Object
        (
            [_type:Zimbra\Common\TypedSequence:private] => Zimbra\Struct\AttributeName
            [elements:protected] => Array
                (
                )
        )
)

So how can I get response? Or my request is incorrect?
Taylorjulie
Posts: 1
Joined: Wed Mar 31, 2021 4:23 am

Re: Zimbra PHP API!!

Postby Taylorjulie » Wed Mar 31, 2021 4:30 am

I have also the same question. I don't how to using data passed back from the response.
Thanks

Return to “Developers”

Who is online

Users browsing this forum: No registered users and 8 guests