Formatting VCard in PHP

后端 未结 3 1221
野性不改
野性不改 2021-01-03 17:30

I\'m trying to generate a VCard via PHP, and them email it out to the user. I wrote an initial script with hard-coded data, but the end-result will fill in the VCard from M

3条回答
  •  抹茶落季
    2021-01-03 17:59

    You are missing a \n at the end of each line. If you look at a normal vCard (with notepad++ for example), it has a CR and LF at the end of each line, the one you create only has CR ('\r'). this works for me:

    $content = "BEGIN:VCARD\r\n";
    $content .= "VERSION:3.0\r\n";
    $content .= "CLASS:PUBLIC\r\n";
    $content .= "FN:Joe Wegner\r\n";
    $content .= "N:Wegner;Joe ;;;\r\n";
    $content .= "TITLE:Technology And Systems Administrator\r\n";
    $content .= "ORG:Wegner Design\r\n";
    $content .= "ADR;TYPE=work:;;21 W. 20th St.;Broadview ;IL;60559;\r\n";
    $content .= "EMAIL;TYPE=internet,pref:joe@wegnerdesign.com\r\n";
    $content .= "TEL;TYPE=work,voice:7089181512\r\n";
    $content .= "TEL;TYPE=HOME,voice:8352355189\r\n";
    $content .= "URL:http://www.wegnerdesign.com\r\n";
    $content .= "END:VCARD\r\n";
    

提交回复
热议问题