Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: PHP SOAP vs Zimbra

  1. #11
    Join Date
    Sep 2007
    Posts
    1
    Rep Power
    8

    Default

    how can i set both attribute and parameters at a time to a function call in PHP:
    Above in this post way to set attribute or param are discussed but not both at a time.
    i need this:
    <SearchRequest limit="10" offset="20">
    <query>is:unread</query>
    </SearchRequest>

    Thanks

  2. #12
    Join Date
    Jun 2008
    Posts
    2
    Rep Power
    7

    Default License?

    Corey Scott,

    First of all, thank you for sharing this, it was very useful to me!

    I don't see any license information in the files. Do you plan to release it in a free license like the GPL ?

    In the meantime, is it possible for me to redistribute it ?
    I started building some functionality around your base class, and I would like to release my code with an open source license, and include your class for better ease of use.

    Thanks in advance,
    Nicolas.
    Last edited by skanx; 06-27-2008 at 06:23 AM.

  3. #13
    Join Date
    Oct 2007
    Location
    Ancaster Ontario Canada
    Posts
    5
    Rep Power
    8

    Default

    Were you ever able to create a way to mass subscribe people in your company to your company Calendar? I'm looking to do a similar thing for our student calendar. Any help would be greatly appreciated!

    Quote Originally Posted by gettyless View Post
    Thanks for sharing your code - I can verify that it works in my test environment! Using your code, I can create a user programmatically through PHP and SOAP. For my test machine, I have win32 apache running - so I had to enable these extensions in my php.ini:

    Code:
    extension=php_openssl.dll
    extension=php_soap.dll
    extension=php_curl.dll
    I'd like to be able to quickly crank out scripts to do what I an across multiple account, for whatever features that aren't officially implemented yet .. if I really need that feature. For example, I'd like to auto-subscribe all employees to the company calendar.

    So, I will probably reuse the authentication code. I've rewritten it into an OO way not sure if it's the best way, design-wise, but it's a start:

    Code:
    <form method="POST" action="soap.php">
    username<br>
    <input type="text" name="username"><br>
    password<br>
    <input type="text" name="password"><br>
    <input type="submit" name="submit" value="submit"><br>
    </form>
    
    <?php
    if (count($_POST))
    {
        $password = $_POST['password'];
        $username = $_POST['username'];
    
        $ZimbraAuth = new ZimbraAuth($username, $password); 
        echo $ZimbraAuth->exec();
    }
    
    class ZimbraAuth
    {
        private $client; 
        private $params; 
        
        function __construct($username, $password)
        {
    
            $this->client = new SoapClient(null,
                array(
                    'location' => "https://zimbra.microsoft.com:7071/service/admin/soap/",
                    'uri' => "urn:zimbraAdmin",
                    'trace' => 1,
                    'exceptions' => 1,
                    'soap_version' => SOAP_1_1,
                    'style' => SOAP_RPC,
                    'use' => SOAP_LITERAL
                )
            );
            
            $this->params = array( new SoapParam($username, "name"), new SoapParam($password, "password") );
            
        }
        
        function exec()
        {
            try 
            {
                //echo "creating header...<br>";
                $soapHeader = new SoapHeader('urn:zimbra','context');
            
                //echo "trying...<br>";        
                $result = $this->client->__soapCall("AuthRequest", $this->params, null,$soapHeader);
                //echo "executed...<br>";    
            } 
            catch (SoapFault $exception) 
            {
                echo "exception caught!...<br><br>EXCEPTION START <<<<<<<<<<< <p>";
                echo $exception . "<br><br>";
                echo ">>>>>>>>>>>> EXCEPTION END<p>";
            
                echo htmlentities($client->__getLastRequest()) . "<br><br>";
                echo htmlentities($client->__getLastRequestHeaders()) . "<br><br>";
                echo htmlentities($client->__getLastResponseHeaders()) . "<br><br>";
                echo htmlentities($client->__getLastResponse()) . "<br><br>";
            
            }
    
            //echo "authToken says: ".$result['authToken'] . "<br>";
            //echo "logged in, continuing<br>";
            return $result['authToken'];
                
                
        }
        
    } 
    ?>
    I'm guessing it would make sense to have a separate ZimbraAuth class, like how people often have a separate database authentication class. Then I use the token for something like $ZimbraUser->create($authToken) or $ZimbraUser->ChangePassword($old, $new, $authToken).

  4. #14
    Join Date
    Nov 2008
    Posts
    2
    Rep Power
    7

    Default Access appointment in zimbra calendar

    I access the zimbra calendar and got the appointment. But it only returns the standard calendar appointment details. Not from other created calendars.

    SOAP:
    <SearchRequest xmlns="urn:zimbraMail" types="appointment" calExpandInstStart="'.$datestart.'000" calExpandInstEnd="'.$dateend.'000">
    <query>in:calendar</query>
    </SearchRequest>

  5. #15
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    4

    Default

    Everyone was tearing their hair out back in 2006 about how to supply attributes to Zimbra SOAP function-name elements when Corey Scott saved the day:

    Quote Originally Posted by Corey Scott View Post
    Its a bit of a kludge (then again what about PHP SOAP isnt ) but I found a solution that works.

    Klude 2 (GetApptSummariesRequest):
    Code:
    Intead of defining the function name:
    $strFunctionName = 'GetApptSummariesRequest';
    
    Sadly you need this instead:
    $strFunctionName = 'GetApptSummariesRequest s="' . $intTsStart . '" e="' . $intTsEnd . '"';
    You get the output you need.
    I've tried this trick for calling the SearchRequest function, which takes a 'type' attribute, but Corey's solution doesn't work for me.

    I have this for my __soapCall():

    Code:
    $result = $client2->__soapCall(
        'SearchRequest type="contact"',         //  function name
        $params,                //  arguments
        null,                       //  options
        $soapHeader);        //  input headers
    But the XML that's produced dumbly repeats the attributes for the closing tag:

    Code:
    <ns1:SearchRequest type="contact">
        <account>item:all</account>
    </ns1:SearchRequest type="contact">
    Corey, anyone, how did you get this to work? How can one use PHP SOAP and attach XML attributes to the function-name element?

    Using Corey's SoapVar trick to attach attributes to *parameter* elements works fine. But I can't see how to do the same for the actual Zimbra functions which themselves require attributes.

    Many thanks for any tips!

Similar Threads

  1. [SOLVED] Clamav problem ? What's happening ?
    By aNt1X in forum Installation
    Replies: 23
    Last Post: 02-14-2008, 05:43 AM
  2. Replies: 8
    Last Post: 02-27-2007, 04:10 AM
  3. svn version still won't start
    By kinaole in forum Developers
    Replies: 0
    Last Post: 10-04-2006, 07:47 AM
  4. Logger
    By jholder in forum Installation
    Replies: 24
    Last Post: 03-31-2006, 11:50 AM
  5. Zimbra MTA and CentOS VPS on OpenVZ
    By czaveri in forum Installation
    Replies: 2
    Last Post: 03-20-2006, 09:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •