Closed sadden3194 closed 3 years ago
Well, you download the entire addressbook each time, and that using the most inefficient method of one request per card. So if you have a lot of cards / huge cards (photos) or a slow connection to the server, it may take a while.
The library currently mostly targets the use case of synchronizing an addressbook with a local cache of the VCards. The incremental synchronization normally is very fast. For your use case, addressbook-query would be best, but it is not yet supported (#2).
So:
synchronize()
as quickstart.php
does. It downloads all cards in a single request, so it saves some overhead. For starters, simply run the original quickstart.php
and see how long it takes.synchronize()
that you are only interested in the EMAIL
property. (quickstart.php
only asks for the FN
property, so you have to adapt the parameter from the example). However, don't get your hopes up as while this feature is defined in the CardDAV spec, I have not yet found a server that supports it :-(I would like to wait for #2 ;) How long it will take? :)
It will take a while until this is properly implemented and tested. There is a quick proof of concept available on the issue2_addressbook_query that you can try. It appears to work for your use case, but I really haven't tested it very much.
$contacts = $abook->query(
['EMAIL' => '%foo%'], // this is the filter conditions, see QueryConditions.php for documentation
[ 'FN', 'EMAIL' ] // this is the list of properties asked for - omit if you want the full vcards
);
foreach ($contacts as $card) {
$card = $card["vcard"];
// whatever you want to do with it
}
Consider this an early proof of concept, which will have bugs and may be subject to change until the released version.
To have composer fetch the branch, change the dependency in composer.json to:
"mstilkerich/carddavclient": "dev-issue2_addressbook_query"
And then run
composer update
Okay, I will wait for the final solution :)
Hi again š
my code works and I am happy. But the request time is very long:
My code:
Output:
This are 30 seconds. Can you explain me why? :(