Code Monkey home page Code Monkey logo

carddav-php's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

carddav-php's Issues

Can't create card baikal server

Baikal server 0.2.7. Every functions work except $carddav->add($vcard) and $carddav->update($vcard, '[UID]');

trying to create:
$vcard= 'BEGIN:VCARD VERSION:3.0 N:Christian;Putzke;;; FN:Christian Putzke EMAIL;type=INTERNET;type=OTHER:[email protected] END:VCARD';
$carddav = new carddav_backend('https://davical.example.com/user/contacts/');
$carddav->set_auth('username', 'password');
$vcard_id = $carddav->add($vcard);

Answer: Fatal error: Uncaught exception 'Exception' with message 'Woops, something's gone wrong! The CardDAV server returned the http status code 415.'

Any idea ?

Get() funktioniert nicht

Guten Morgen!,

Ich habe eine Synology DS718+ als CardDAV Server im Einsatz.
Gerne würde ich via PHP Kontakte hinzufügen - mit Hilfe Ihres Scripts gelingt mir dies auch.
Allerdings funktioniert die Abfrage nicht.

Mit dem Code: echo $carddav->get();
Erhalte ich nur folgende Ausgabe:

/carddav/SynoContacts//carddav//carddav/SynoContacts//carddav/SynoContacts//carddav/SynoContacts//carddav/SynoContacts//carddav/SynoContacts//carddav/SynoContacts/HTTP/1.1 200 OK

Dieser Part:

$carddav->enable_debug();
$carddav->get();
var_dump($carddav->get_debug());

bringt folgendes Resultat:

array(1) {
  [0]=>
  array(7) {
    ["response"]=>
    string(1393) "
/carddav/SynoContacts//carddav//carddav/SynoContacts//carddav/SynoContacts//carddav/SynoContacts//carddav/SynoContacts//carddav/SynoContacts//carddav/SynoContacts/HTTP/1.1 200 OK"
    ["http_code"]=>
    int(207)
    ["url"]=>
    string(52) "https://cardDAV_URL:port/carddav/SynoContacts/"
    ["method"]=>
    string(8) "PROPFIND"
    ["content"]=>
    NULL
    ["content_type"]=>
    NULL
    ["header"]=>
    string(184) "HTTP/2 207 
server: nginx
date: Sun, 03 Jan 2021 14:52:22 GMT
content-type: text/xml; charset=utf-8
content-length: 1393
dav: 1, 2, 3, calendar-access, addressbook, extended-mkcol"
  }
}


Works good with SOGo, SabreDAV fix for simplify() method

Hi,

SOGo catalog list for simplify:

<?xml version="1.0" encoding="utf-8" ?> 
- <D:multistatus xmlns:ap="http://apache.org/dav/props/" xmlns:D="DAV:">
- <D:response>
  <D:href>/SOGo/dav/sogo1/Contacts/</D:href> 
- <D:propstat>
  <D:status>HTTP/1.1 200 OK</D:status> 
- <D:prop>
  <D:getlastmodified>Mon, 25 Jun 2012 08:45:47 -0400</D:getlastmodified> 
  <D:getetag>"None"</D:getetag> 
- <D:resourcetype>
  <D:collection /> 
  </D:resourcetype>
  <D:getcontenttype>httpd/unix-directory</D:getcontenttype> 
  <D:displayname>Contacts</D:displayname> 
  <D:href>/SOGo/dav/sogo1/Contacts/</D:href> 
  <ap:executable>0</ap:executable> 
  </D:prop>
  </D:propstat>
  </D:response>
+ <D:response>
  <D:href>/SOGo/dav/sogo1/Contacts/personal/</D:href> 
- <D:propstat>
  <D:status>HTTP/1.1 200 OK</D:status> 
- <D:prop>
  <D:getlastmodified>Mon, 25 Jun 2012 08:45:47 -0400</D:getlastmodified> 
  <D:getetag>"None"</D:getetag> 
- <D:resourcetype>
  <D:collection /> 
  <vcard-collection xmlns="http://groupdav.org/" /> 
  <addressbook xmlns="urn:ietf:params:xml:ns:carddav" /> 
  </D:resourcetype>
  <D:getcontenttype>httpd/unix-directory</D:getcontenttype> 
  <D:displayname>Hermeegille</D:displayname> 
  <D:href>/SOGo/dav/sogo1/Contacts/personal/</D:href> 
  <ap:executable>0</ap:executable> 
  </D:prop>
  </D:propstat>
  </D:response>
  </D:multistatus>

produces this output:

<?xml version="1.0" encoding="UTF-8" ?> 
- <response>
- <addressbook_element>
  <display_name>Contacts</display_name> 
  <url>http://sogo-demo.inverse.ca/SOGo/dav/sogo1/Contacts/</url> 
  <last_modified>Mon, 25 Jun 2012 08:45:47 -0400</last_modified> 
  </addressbook_element>
- <addressbook_element>
  <display_name>Hermeegille</display_name> 
  <url>http://sogo-demo.inverse.ca/SOGo/dav/sogo1/Contacts/personal/</url> 
  <last_modified>Mon, 25 Jun 2012 08:45:47 -0400</last_modified> 
  </addressbook_element>

SabreDAV returns list folders in following format:

  <?xml version="1.0" encoding="utf-8" ?> 
- <d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/" xmlns:card="urn:ietf:params:xml:ns:carddav">
- <d:response>
  <d:href>/trunk/dav.php/addressbooks/test%40localhost/</d:href> 
- <d:propstat>
- <d:prop>
- <d:resourcetype>
  <d:collection /> 
  </d:resourcetype>
  </d:prop>
  <d:status>HTTP/1.1 200 OK</d:status> 
  </d:propstat>
  </d:response>
- <d:response>
  <d:href>/trunk/dav.php/addressbooks/test%40localhost/Default/</d:href> 
- <d:propstat>
- <d:prop>
- <d:resourcetype>
  <d:collection /> 
  <card:addressbook /> 
  </d:resourcetype>
  </d:prop>
  <d:status>HTTP/1.1 200 OK</d:status> 
  </d:propstat>
  </d:response>
+ <d:response>
  <d:href>/trunk/dav.php/addressbooks/test%40localhost/Collected/</d:href> 
- <d:propstat>
- <d:prop>
- <d:resourcetype>
  <d:collection /> 
  <card:addressbook /> 
  </d:resourcetype>
  </d:prop>
  <d:status>HTTP/1.1 200 OK</d:status> 
  </d:propstat>
  </d:response>
  </d:multistatus>

simplify() returns empty node. You may add the following fix:


    private function simplify($response, $include_vcards = true)
    {
        $response   = $this->clean_response($response);
        $xml        = new SimpleXMLElement($response);

        $simplified_xml = new XMLWriter();
        $simplified_xml->openMemory();
        $simplified_xml->setIndent(4);

        $simplified_xml->startDocument('1.0', 'utf-8');
            $simplified_xml->startElement('response');

                foreach ($xml->response as $response)
                {
                    if (preg_match('/vcard/', $response->propstat->prop->getcontenttype) || preg_match('/vcf/', $response->href))
                    {
                        $id = basename($response->href);
                        $id = str_replace('.vcf', null, $id);

                        if (!empty($id))
                        {
                            $simplified_xml->startElement('element');
                                $simplified_xml->writeElement('id', $id);
                                $simplified_xml->writeElement('etag', str_replace('"', null, $response->propstat->prop->getetag));
                                $simplified_xml->writeElement('last_modified', $response->propstat->prop->getlastmodified);

                                if ($include_vcards === true)
                                {
                                    $simplified_xml->writeElement('vcard', $this->get_vcard($id));
                                }
                            $simplified_xml->endElement();
                        }
                    }
                    else if (preg_match('/unix-directory/', $response->propstat->prop->getcontenttype))
                    {
                        if (isset($response->propstat->prop->href))
                        {
                            $href = $response->propstat->prop->href;
                        }
                        else if (isset($response->href))
                        {
                            $href = $response->href;
                        }
                        else
                        {
                            $href = null;
                        }

                        $url = str_replace($this->url_parts['path'], null, $this->url) . $href;
                        $simplified_xml->startElement('addressbook_element');
                            $simplified_xml->writeElement('display_name', $response->propstat->prop->displayname);
                            $simplified_xml->writeElement('url', $url);
                            $simplified_xml->writeElement('last_modified', $response->propstat->prop->getlastmodified);
                        $simplified_xml->endElement();
                    }
                    else // fix here
                    {
                        if (isset($response->href))
                        {
                            $href = $response->href;

                          $url = str_replace($this->url_parts['path'], null, $this->url) . $href;
                          $simplified_xml->startElement('addressbook_element');
                          $simplified_xml->writeElement('display_name', $href);
                          $simplified_xml->writeElement('url', $url);
                          $simplified_xml->endElement();


                        }                        
                    }
                }

            $simplified_xml->endElement();
        $simplified_xml->endDocument();

        return $simplified_xml->outputMemory();
    }

SOGo - get_vcard

In get_vcard - the query appends .vcf to the URL

I have had to change it to reflect:
//~ $result = $this->query($this->url . $vcard_id . '.vcf', 'GET');
$result = $this->query($this->url . $vcard_id, 'GET');

Feature Request REST Wrapper

It would be VERY VERY awesome to have this backend wrapped in Rest.
If you have already seen the comments on your roundcube plugin, i mistakenly thought it was a mysql client for carddav and not the other way around.

Having a mysql carddav client would be totally awesome.
Having one where you could have multiple accounts would be even more awesome.
Even better, wrapping your plugin and turning it into an API would be so powerful.
It would allow any language to use it, so long as it was hosted where php was allowed.
There are not too many dav clients out there, (none in ASP that i could find)

Here is kind of what i have in mind?

Any plans, ideas?

Create {returns the id of the record "recordid"}
http://myserver.com/davphp/update/?server=http://carddavserver&username=3342&password=4334&vcardddata=........

Update
http://myserver.com/davphp/update/?server=http://carddavserver&username=3342&password=4334&recordid=xxx&vcardddata=........

Delete
http://myserver.com/davphp/update/?server=http://carddavserver&username=3342&password=4334&recordid=xxx

Cannot connect to owncloud 3.0

Hello,

I have an owncloud 3.0 server but cannot connect to it.

In roundcube's carddav setting I use 'http:///owncloud/apps/contacts/carddav.php' for 'server'. Then I provide user name and password in the separate fields. Click on 'save' displays 'internal server error'.

Is the URL I use correct or do I have to add the user name, name of addressbook or something else?

Best regards

Holger

Would like to use this for Caller ID matching

Project: Caller ID Superfecta https://github.com/tm1000/Caller-ID-Superfecta/

I would like to adapt this code to look up a name for a known phone number from an OS x server. I am not very strong with PHP and I am hoping to get a bit of help on how to structure the query. I assume I can adapt the simple query for this purpose:

$carddav = new carddav_backend('https://davical.example.com/user/contacts/');
$carddav->set_auth('username', 'password');
echo $carddav->get();

I have confirmed that I have a server connection with the supplied "check connection" code, but I don't know how to actually search records for the phone number. Any pointers?

Don't works with Synology CardDAV Server

Here my code:

$carddav = new carddav_backend('http://ip:8008/addressbooks/users/contacts/addressbook/');
$carddav->set_auth('contacts', 'mypw');
echo $carddav->get();

And the error:

Fatal error: Uncaught exception 'Exception' with message '1Woops, something's gone wrong! 
The CardDAV server returned the http status code 401.' in /volume1/web/carddav.php:285 
Stack trace: #0 /volume1/web/contacts.php(9): carddav_backend->get(false) #1 {main} thrown in /volume1/web/carddav.php on line 285

Can't interact with ownCloud cardDAV-Server

I'm going to develop a frontend for cardDAV-Servers and for this purpose I tried to use your class with my instance of ownCloud for testing. I can connect to the server but I can't get any data from it. Adding contacts is also not possible.

This ist my code:

<?php

include_once "CardDAV-PHP/carddav.php";


$carddav = new carddav_backend('https://dblx.io/owncloud/apps/contacts/carddav.php');
$carddav->set_auth('test', 'test');

var_dump($carddav->check_connection());

echo $carddav->get();

$vcard = 'BEGIN:VCARD
VERSION:3.0
UID:1f5ea45f-b28a-4b96-25as-ed4f10edf57b
FN:Christian Putzke
N:Christian;Putzke;;;
EMAIL;TYPE=OTHER:[email protected]
END:VCARD';

$carddav->add($vcard);

?>

And this is the result I get.

bool(true)
<?xml version="1.0" encoding="UTF-8"?>
<response/>

You can use the credentials for my server for testing, if you want to. If I can help finding errors, let me know.

Does not import email addresses of type 'andere'

Hello,

I am using CardDAV-PHP with owncloud 3.0 which keeps the contacts of my MacBook. Unfortunately the email adresses of type 'Andere' are not imported in roundcube. The types 'Privat' and 'Arbeit' work fine.

don't work with darwin calendarserver

Hello,

i had installed darwin calendarserver (open source caldav/carddav implementation).
it's working fine with osx adressbook and ios.
and it works with atmail webmail interface too.

if i want to use it with your carddav-plugin for roundcubemail i get the following problems:

on setup i have to enter hostname with port because without it i get the follwing error: "Serverfehler! (Internal Server Error)".
after this it creates the new carddav-record anyway and i can use it.

if i setup hostname with port (8800) i get no error on setup.

if i want to sync my contacts with carddav server i get always (on both setups) the following message in frontend: "Serverfehler! (Internal Server Error)" and in logfile this: "CardDAV-Server XML-Response is malformed. Synchronization aborted!"

if you need an account to test against my carddav-server i can create one for you.

best regards,
Frederic

iCloud compatible

Replace

    curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

to
curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

To make it iCloud compatible, this should be in the notes somewhere.

Add method take 2 arguments

I modified the add method to pass the UUID of the vCard. This it can be or not generated.

    public function add($vcard, $vcard_id = false)
    {
            if (!$vcard_id) {
                    $vcard_id = $this->generate_vcard_id();
            }
           $vcard = $this->clean_vcard($vcard);
          ....
 }

osx server snow leopard - auth bug -> fixed

I couldn't authenticate to the OSX Server Snow Leopard and to fix it I changed the auth method:

        //curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);

Of course CURLAUTH_ANY should also support DIGEST, but it seams that the server denies the login if you use it! With DIGEST it works perfectly.

curl_setopt() issue

On version v0.5.2
carddav.php:503 curl_setopt() expects exactly 3 parameters, 2 given (2)
I believe the same apply to version 0.6.

The error appear on Debian Squezze with php5
$ php -v
PHP 5.3.3-7+squeeze13

Compatible with zimbra contacts?

require_once('carddav.php');

$carddav = new carddav_backend('https://domain.com/dav/[email protected]/contacts/');
$carddav->set_auth('[email protected]', 'test1233');
var_dump($carddav->check_connection());

been trying to connect to my zimbra 7.13 zimbra server, but only getting false back. Havent gotten any errors or debug information at all. Any ideas?

XML Parser Warning

Hello,

your tool just made my day ;-)
but I've found a small bug: The XML Parser throws the following warnings when using PHP 5.2.14 with libxml 2.6.32 and SabreDAV:

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 2: parser warning : xmlns:d: 'DAV:' is not a valid URI in carddav.php on line 354

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:card="urn:iet in carddav.php on line 354

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in carddav.php on line 354

They do not appear when using PHP 5.3.1 and libxml 2.7.3. I fixed this issue by adding this line to your clean_response function:

$response = preg_replace('/xmlns:d="[^\"]*"/i', '', $response);

Searching

Retrieving a vCard once you know the id is easy enough

but what would the search syntax be

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.