Git Product home page Git Product logo

Comments (5)

jrast avatar jrast commented on July 26, 2024

The example you posted is not in the vCard-Format. Have a look at the vCard-Format here: http://en.wikipedia.org/wiki/VCard

from vcard-parser.

gopeter avatar gopeter commented on July 26, 2024

Unfortunately, Apple Addressbook produces exactly such vCards. I've exported a vCard, opened it in TextEdit and got this:

BEGIN:VCARD
VERSION:3.0
PRODID:-//Apple Inc.//Address Book 6.1.2//EN
N:lastname;firstname;;;
FN:firstname lastname
item1.ADR;type=WORK;type=pref:;;street;city;;zip;country
item1.X-ABADR:de
CATEGORIES:Default Address Book,CategoryXY
UID:b1341197-52bb-4c6a-8d2a-9e9c4d3b570f
X-ABUID:28E7998F-D09C-4233-B268-4FA8173174E7:ABPerson
END:VCARD

from vcard-parser.

jrast avatar jrast commented on July 26, 2024

Ok, i see the problem. Apple Adressbook uses Groups for some Properties.
Seems to be OK according to this RCF: http://tools.ietf.org/html/rfc6350#section-3.3

from vcard-parser.

gopeter avatar gopeter commented on July 26, 2024

Little bit of dirty code helps me solving the problem

// loop each group of addresses (i have only 2 addresses in one vcard)
for ($i = 1; $i <= 2; $i++) {

    // get field identifier. $single_vcard is our vCard Object
    $address_field = "item$i.ADR";
    $address_raw = $single_vcard -> $address_field;

    // get raw address informations
    $address = $address_raw[0]['Value'];

    // call a vCard function to parse raw address informations to an array with semantic keys
    $address = vCard::ParseStructuredValue($address,'adr');

    // get first type value (work, home, office, ...), cause we dont need the "pref" value, that apples addressbook create
    $type = $address_raw[0]['Type'][0];

    // save vars to array
    $contacts["address_$i"]['address_type'] = $type;
    $contacts["address_$i"]['address_street'] = $address['StreetAddress'];
    $contacts["address_$i"]['address_zip'] = $address['PostalCode'];
    $contacts["address_$i"]['address_city'] = $address['Locality'];
    $contacts["address_$i"]['address_country'] = $address['Country'];
}

from vcard-parser.

pilsetnieks avatar pilsetnieks commented on July 26, 2024

I made some changes so that those itemized elements aren't completely ignored so it is now possible to get that data, too. However those Apple Address Book extensions aren't supported and are ignored for now (the elements starting with X-AB...)

from vcard-parser.

Related Issues (20)

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.