好像一个plonker,我认为这很容易。
我们有一个客户端详细信息的弹出窗口,看起来像一个vCard(但风格很大),都是通过我们的数据库动态传播的。
所以我只是觉得不用担心,我们可以在vcard中使用php,并解析相关信息..这样,当用户点击d / l链接时,他们会获得正确的vCard详细信息..
嗯嗯,找到关于vCards等的信息很难。
所以这是vcard.vcf的片段
BEGIN:VCARD
VERSION:2.1
N;LANGUAGE=en-in:Name;Type;Your
FN:Type Your Name
TEL;WORK;VOICE:+1 (800) 123 4567
示例TEL在我们的php中呈现:<?=$r['tel'];?>
那么我们如何在vcard中获取php以使其可用..任何提示都值得赞赏。
答案 0 :(得分:3)
以下是包含一个人信息的VCard文件示例:
vCard 2.1:
BEGIN:VCARD
VERSION:2.1
N:Gump;Forrest
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
TEL;WORK;VOICE:(111) 555-1212
TEL;HOME;VOICE: (404) 555-1212
ADR;WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:100 Waters Edge=0D=0ABaytown, LA 30314=0D=0AUnited States of America
ADR;HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:42 Plantation St.=0D=0ABaytown, LA 30314=0D=0AUnited States of America
EMAIL;PREF;INTERNET:forrestgump@example.com
REV:20080424T195243Z
END:VCARD
vCard 3.0:
BEGIN:VCARD
VERSION:3.0
N:Gump;Forrest
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
PHOTO;VALUE=URL;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif
TEL;TYPE=WORK,VOICE:(111) 555-1212
TEL;TYPE=HOME,VOICE: (404) 555-1212
ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America
LABEL;TYPE=WORK:100 Waters Edge\nBaytown, LA 30314\nUnited States of America
ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
LABEL;TYPE=HOME:42 Plantation St.\nBaytown, LA 30314\nUnited States of America
EMAIL;TYPE=PREF,INTERNET:forrestgump@example.com
REV:20080424T195243Z
END:VCARD
将所有数据存入共振峰后,您可以使用比较字符串变量:
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"vCard.vcf\"");
echo $data;
?>
如果您希望创建文件并输出指向该文件的链接,也可以这样做:
$ourFileName = "vCard.vcf";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
我希望这能使你走上正轨,并且我已正确理解你的问题。
<强>解答:强>
<?php
$vCard = "BEGIN:VCARD
VERSION:3.0
N:Gump;Forrest
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
PHOTO;VALUE=URL;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif
TEL;TYPE=WORK,VOICE:(111) 555-1212
TEL;TYPE=HOME,VOICE:(404) 555-1212
ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America
LABEL;TYPE=WORK:100 Waters Edge\nBaytown, LA 30314\nUnited States of America
ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
LABEL;TYPE=HOME:42 Plantation St.\nBaytown, LA 30314\nUnited States of America
EMAIL;TYPE=PREF,INTERNET:forrestgump@example.com
REV:20080424T195243Z
END:VCARD";
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"vCard.vcf\"");
echo $vCard;
?>
以上代码将允许用户下载$ vCard中保存的vCard。在您的情况下,您需要添加自己的数据,如下所示:
$vCard = "BEGIN:VCARD
VERSION:3.0
N:Gump;Forrest
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:".$array['title']."
PHOTO;VALUE=URL;TYPE=GIF:".$array['weblink']."
TEL;TYPE=WORK,VOICE:".$array['WORKNUM']."
TEL;TYPE=HOME,VOICE:".$array['HOMENUM']."
ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;".$array['Country']."
LABEL;TYPE=WORK:100 Waters Edge\nBaytown, LA 30314\n".$array['Country']."
ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;".$array['Country']."
LABEL;TYPE=HOME:42 Plantation St.\nBaytown, LA 30314\nUnited States of America
EMAIL;TYPE=PREF,INTERNET:forrestgump@example.com
REV:20080424T195243Z
END:VCARD";
答案 1 :(得分:-2)
<button onclick="myFunction()">Try it</button>
<img src="" id="img" />