Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old 09-05-2007, 11:38 PM
Starter Member
 
Posts: 1
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
Reply With Quote
  #12 (permalink)  
Old 06-27-2008, 05:21 AM
Starter Member
 
Posts: 2
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 05:23 AM..
Reply With Quote
  #13 (permalink)  
Old 11-05-2008, 08:31 AM
Junior Member
 
Posts: 5
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).
Reply With Quote
  #14 (permalink)  
Old 11-10-2008, 10:57 PM
Starter Member
 
Posts: 2
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>
Reply With Quote
  #15 (permalink)  
Old 02-05-2011, 03:41 AM
New Member
 
Posts: 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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.