Comments (5)
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.
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.
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.
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.
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)
- PHP Parse error HOT 1
- E-mail is not parsed from vCard HOT 2
- Fatal error: allowed mem size on vcard with photo HOT 3
- X-Attributes in Apple Addressbook photos HOT 1
- Wrong parsing of "adr" field
- Does not parse Apples vCard very well
- Difference between 2.1 and 3.0 versions
- vCard.php is not complete
- note field missing HOT 1
- Howto create new entry with type and sub element (eg: adr) HOT 5
- Unable to parse multiple contacts in single Vcard HOT 1
- Apple vCards provide no CATEGORIES
- Case problem with begin and end tags
- Fatal error: Uncaught Error: Xdebug has detected a possible infinite loop
- Parser chokes on AGENT HOT 1
- Patch with comments and proposed changes HOT 3
- vCard.php Parse Error HOT 3
- problematic vcard from Apple Addressbook HOT 2
- Empty vcard show as valid HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vcard-parser.