Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing google address book #16

Open
tttp opened this issue Oct 14, 2012 · 9 comments
Open

Accessing google address book #16

tttp opened this issue Oct 14, 2012 · 9 comments

Comments

@tttp
Copy link

tttp commented Oct 14, 2012

Hi,

Have you been able to connect to google?

http://support.google.com/mail/bin/answer.py?hl=en&answer=2753077

tried

$carddav = new carddav_backend('https://google.com/');
$carddav->enable_debug();
$carddav->set_auth('[email protected]', 'password');

but fails.

@white-gecko
Copy link

I found another link (German) saying, that the google caldav url is: https://google.com/m8/carddav/principals/__uids__/YourName%40gmail.com/lists/default/ but I get another exception telling, that the server returned error #404.

@white-gecko
Copy link

I found the cause for my error #404. In line 299 the .vcf ending is appended, which shouldn't be there for google contacts. Maybe @graviox should add a parameter $ending or something like that.

@white-gecko
Copy link

maybe you could also use the content of the <d:href> tag which is included in the raw output and seams to contain the whole uri of the contact/vcard

@chellmann
Copy link

i would also love support for google ;-)

@pilosof
Copy link

pilosof commented Dec 30, 2012

@white-gecko i'm getting error 405 ... how did you solve this ?

removing the .vcf ending didn't work for me..

using the german url and removing .vcf just hangs...

@white-gecko
Copy link

Regarding to wikipedia error 405 is method not allowed, meaning something with GET/POST/… is wrong.

My diff for carddav.php is:

$ git diff carddav.php
diff --git a/carddav.php b/carddav.php
index ec76f65..ff4e9c6 100644
--- a/carddav.php
+++ b/carddav.php
@@ -296,7 +296,7 @@ class carddav_backend
        public function get_vcard($vcard_id)
        {
                $vcard_id       = str_replace('.vcf', null, $vcard_id);
-               $result         = $this->query($this->url . $vcard_id . '.vcf', 'GET');
+               $result         = $this->query($this->url . $vcard_id, 'GET');

                switch ($result['http_code'])
                {

And I retrieve the contact data with following script:

<?php
require_once('carddav.php');

$carddav = new carddav_backend('https://google.com/m8/carddav/principals/__uids__/myname%40gmail.com/lists/default/');
$carddav->set_auth('[email protected]', 'mypassword');
$cards = $carddav->get(false);

$cardXml = new SimpleXMLElement($cards);

foreach ($cardXml->element as $element) {
    echo $carddav->get_vcard($element->id);
}

@jethrocarr
Copy link

I bumped into this issue as well... I don't think Google is doing anything wrong with their CardDAV setup, but it is certainly different to the other CardDAV servers I've been trying.

According to RFC 6352 (http://tools.ietf.org/html/rfc6352), "File names for vCards are commonly suffixed by ".vcf", and clients may choose to use the same convention for URLs." so .vcf is somewhat unclearly defined in that the RFC implies that both with and without the extension is acceptable.

I've committed what I hope is a good fix for the issue - essentially I've added the ability to set the extension to be used for the vcard queries, as well as a check to set_url that automatically configures it correctly when using Google.

See:
jethrocarr@2c3af2f

@mrahmadt
Copy link

Hello

I think google URL has been changed to

https://google.com/carddav/v1/principals/YourName%40gmail.com/

@clemenlg
Copy link

clemenlg commented Aug 18, 2017

Hi @mrahmadt,
It don't work with google, neither with this url.
Now it returns a 200 response, with the url https://google.com/carddav/v1/principals/[email protected]/lists/default, but content and content_type are null, and the header returns string(1011) "HTTP/1.1 401 Unauthorized

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants