vCard Notes
vCard is a specification for representing contact information. It’s used to move information between address books in a non-proprietary format, and to download or even upload contact information from web sites.
Apple’s Macintosh Address Book supports vCard as an export and import format as does Microsoft Outlook.
A vCard can contain things like addresses, phone numbers, email addresses, even photographs.
I’m working on a web site which stores contact information for businesses and I want to be able to make that information available to my users in vCard format. So… I’m coding in Perl. There are two Perl packages that look helpful - Net::vCard and Text::vCard. It turns out that Text::vCard is a more recent version of the same codebase as Net::vCard.
Text::vCard provides methods for creating a vCard and setting the data it contains. You can then create an address book using Text::vCard::Addressbook and use its export function to get the actual vCard text.
The format’s not difficult. Here’s a sample vCard exported by Apple’s Address Book:
BEGIN:VCARD
VERSION:3.0
N:;;;;
FN:Garfield Smokehouse
ORG:Garfield Smokehouse;
EMAIL;type=INTERNET;type=WORK;type=pref:smokey@garfieldsmokehouse.com
TEL;type=WORK;type=pref:(603) 469-3225
TEL;type=WORK;type=FAX:603-469-3298
item1.ADR;type=WORK;type=pref:;;PO Box 236\n163 Main St.;Meriden;NH;03770;USA
item1.X-ABADR:us
PHOTO;BASE64:
/9j/4AAQSkZJRgABAQAAAQABAAD/7QAcUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAD/2wBDAAEB
...
X-ABShowAs:COMPANY
X-ABUID:848FA266-2359-4AAB-9014-C6C342BC80C8\:ABPerson
END:VCARD
If you want to just generate this yourself, you’ll want to take a look at the vCard specification in RFC 2425 and RFC 2426. If the RFCs are a bit impenetrable to you, check out this page at Hypercontent. Also try experimenting; export a few vCards and you’ll see what other programs generate.
Once you’ve got your vCard-generating code working, you’ll need to download the vCard from your web server. The MIME type for vCards is “text/x-vcard”. And if you send a Content-Disposition header with a filename, you’ll force the web browser to download the vCard with that filename as its default rather than accidentally show the content of the vCard as if it were a web page.
If you’re interested in vCards, you may also be interested in the hCard microformat. Microformats use HTML/CSS classes to identify blocks of structured information. Using hCard, you can effectively embed contact information in a web page in such a way that software can extract it while a human can read it. Unfortunately, very few web browsers currently detect and support hCard; hopefully that will change in the near future.
[tags]macintosh, address book, vcard, text::vcard, net::vcard, outlook, contact information[/tags]



Add to del.icio.us
Digg it!
Add to Google Bookmarks
Add to Netscape
Add to Windows Live
Add to Yahoo! My Web
RSS




