portable contacts to vCard converter

54 views
Skip to first unread message

Joseph Smarr

unread,
Dec 18, 2008, 6:19:56 PM12/18/08
to PortableContacts
Hi guys, I just released a PHP library (and a hosted version on Plaxo) that can take any Portable Contacts JSON output and dump it as a vCard. You can try it out at http://www.plaxo.com/pdata/vcardTest and see the code at http://code.google.com/p/portablecontacts/source/browse/code/php/VcardSerializer.php

This serves both a practical and symbolic purpose: practically speaking, it makes it easy to support legacy clients that expect vCard files (e.g. Outlook, Mac Address Book, etc.) by being a Portable Contacts Provider--just convert your output as a post-transform and bingo, all those tools can consume it. And since Portable Contacts allows some basic filtering operations, it's actually a pretty powerful combination, e.g. I can now easily download vCards with name and mailing address for all my "family connections" in Plaxo (just in time for writing holiday cards). :)

And symbolically, it shows just how compatible Portable Contacts and vCard are--the code is increddibly simple, and the mappings are all one-to-one, and this is shown concretely by looking at the code. In fact, when I realized that there weren't any high-quality vCard generator libraries for PHP, and I decided to write one myself, it occurred to me that any serialization code needs an "object representation" of the data as input, and what better object representation for vCard data than the parsed JSON from Portable Contacts! In other words, it's not just a format-converter, Portable Contacts *is* the logical object representation of vCard, and this code again demonstrates that nicely.

Check it out and let me know what you think. Among other things, we can now extend Kevin's famous hCard->vCard->PoCo "long pipe" even further:

Step 1: start with kevin's twitter followers as a vCard:
http://technorati.com/contacts/twitter.com/kevinmarks

Step 2: convert it from vCard to Portable Contacts (we built this previously):
http://www.plaxo.com/pdata/vcard?vcard=&vcardUrl=technorati.com%2Fcontacts%2Ftwitter.com%2Fkevinmarks&format=json&plaintext=1&pretty=1

Step 3: use that as input to re-generate the vCard and complete the cycle (this is new):
http://www.plaxo.com/pdata/pc2vcf?pcUrl=http%3A%2F%2Fwww.plaxo.com%2Fpdata%2Fvcard%3Fvcard%3D%26vcardUrl%3Dtechnorati.com%252Fcontacts%252Ftwitter.com%252Fkevinmarks%26format%3Djson

Step 4: use this as input and go to step 2; repeat until your brain hurts (or you hit the HTTP GET length-limit). :)

Thanks, js
Reply all
Reply to author
Forward
0 new messages