0

raI setting up a script to generate vcard files from info in a wordpress custom post. It seems to work, but the resulting file is not accepted as valid by 'Contacts' on mac.

This is the file content:

BEGIN:VCARD
VERSION:3.0
N:Hans H;Hansen
PREFIX:Mr
FN:Hans H. Hansen
ORG:Chemical Tankers
TITLE:Managing Director
PHOTO;VALUE=URL;TYPE=jpg:http://test.test.org/wp-content/uploads/sites/2/2013/04/jan_johansen.jpg
TEL;TYPE=WORK,VOICE:+47 55 55 55 55
TEL;TYPE=HOME,VOICE:
TEL;TYPE=CELL,VOICE:+47 99 99 99 99
ADR;TYPE=WORK:;;Weravg 5, Os;Stavanger;P.O.Box 1225, Os;Norway
LABEL;TYPE=WORK:Weravg 5, Os, Stavanger Stavanger\r\nNorway
EMAIL;TYPE=PREF,INTERNET:joar.hansen@sdomain.no
REV:20130408T195243Z\r\n 
END:VCARD

I even want to include these two lines, but I am not sure about the "postal" type address, so I’ll try that after the rest is ok:

ADR;TYPE=POSTAL:;;Weraveg 5, Os;Stavanger;P.O.Box 1225, Os;Norway
LABEL;TYPE=WORK:Weraveg 5, Os, Stavanger Stavanger\r\nNorway

Where is my error?

hal
  • 33
  • 1
  • 4
  • The error, it turns out, doesn't show in the cited text: I had some spaces preceding the text in each line, which caused the trouble. – hal Apr 09 '13 at 07:15
  • A few comments: (1) The proper way to encode a newline in a property value is to use the `\n` escape sequence. The vCard consumer is required to decode this into the local system's newline sequence when parsing the vCard (so, `\r\n` for Windows). (2) There's no `PREFIX` property. If you need to specify a prefix, include it in the `N` property like so: `N:Hans H;Hansen;;Mr;`. (3) If you need to include a comma character inside of an `ADR` property, you should escape it with a backslash. Otherwise, it may not parse correctly. – Michael Apr 09 '13 at 12:54

0 Answers0