Zimbra PHP API!!

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

Zimbra PHP API!!

Post by Jhonmicky »

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!!

Post by rcardozo1987 »

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: 242
Joined: Tue Jun 17, 2014 3:31 am
Contact:

Re: Zimbra PHP API!!

Post by barrydegraaff »

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
Email: barry.degraaff [at] synacor [dot] com
Admin of Zimbra-Community Github: https://github.com/orgs/Zimbra-Community/ and the
Zimlet Gallery https://gallery.zetalliance.org/extend/
dad1969
Posts: 2
Joined: Tue Sep 15, 2015 4:29 am

Re: Zimbra PHP API!!

Post by dad1969 »

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?
Post Reply