vCard 通过 php 传播来自 dB 的信息

发布于 2024-11-13 06:51:24 字数 496 浏览 4 评论 0原文

好吧,就像一个笨蛋一样,我认为这很容易。

我们有一个弹出窗口,其中包含客户详细信息,看起来像 vCard(但风格很重),所有这些都通过我们的数据库动态传播。

所以我只是想是的,不用担心,我们可以在 vcard 中使用 php,并解析相关信息..以便 wneh 用户单击 d/l 链接,他们会获得正确的 vCard 详细信息..

嗯,不,查找有关 vCard 等的信息是难的。

所以这里是 vcard.vcf 示例 TEL 的片段

BEGIN:VCARD
VERSION:2.1
N;LANGUAGE=en-in:Name;Type;Your
FN:Type Your Name
TEL;WORK;VOICE:+1 (800) 123 4567

在我们的 php 中呈现,如下所示:

那么我们如何在 vcard 中获取 php使其可用......任何提示表示赞赏。

Ok like a plonker I thought it would be easy as.

We have a popup with clients details in, to look like a vCard ( but heavily styled ) all propagated via our db on the fly.

So I just thought yeah no worries, we can use php within the vcard, and parse the relevant info .. so that wneh user clicks d/l link they get the correct vCard details..

Hmmm nope, and finding info about vCards etc is hard.

So here is a snippet of the 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

Example TEL is rendered in our php like: <?=$r['tel'];?>

So how do we get php within the vcard to make it useable.. any hints appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光磨忆 2024-11-20 06:51:24

以下是包含一个人的信息的 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:[email protected]
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:[email protected]
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:[email protected]
    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:[email protected]
    REV:20080424T195243Z
    END:VCARD";

The following is an example of a VCard file containing information for one person:

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:[email protected]
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:[email protected]
REV:20080424T195243Z
END:VCARD

Once you have all your data in a formant you can use say a string variable :

<?php
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=\"vCard.vcf\"");
    echo $data;
?>

You can also if you wish create the file and off a link to that:

$ourFileName = "vCard.vcf";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);

I hope this puts you on track and that I have understood your question correctly.

ANSWER:

<?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:[email protected]
    REV:20080424T195243Z
    END:VCARD";

    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=\"vCard.vcf\"");
    echo $vCard;
?>

The above code will allow the user to to download the vCard held in $vCard. In your case you would need to add your own data an example of how this would go is shown below:

    $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:[email protected]
    REV:20080424T195243Z
    END:VCARD";
倾城泪 2024-11-20 06:51:24
$vCard ="BEGIN:VCARD N:Mohammad Alam FN:Mohammad Alam BDAY:19910101 TEL;"
."HOME:+8801839095329 TEL;".
"CELL:+88001917579643 EMAIL:[email protected] ".
"URL:www.yellowjobs.com.bd NOTE:Software Programmer(PHP,css codeigniter Framework"
.",Joomla,wordpress,zen cart) \nVisit : www.datacenter.com.bd\nvisit:"
." www.yellowjobs.com.bd\nwww.e vents365.com.bd \nI'm specialist Codeigniter Framework.".
" END:VCARD";
$vCard ="BEGIN:VCARD N:Mohammad Alam FN:Mohammad Alam BDAY:19910101 TEL;"
."HOME:+8801839095329 TEL;".
"CELL:+88001917579643 EMAIL:[email protected] ".
"URL:www.yellowjobs.com.bd NOTE:Software Programmer(PHP,css codeigniter Framework"
.",Joomla,wordpress,zen cart) \nVisit : www.datacenter.com.bd\nvisit:"
." www.yellowjobs.com.bd\nwww.e vents365.com.bd \nI'm specialist Codeigniter Framework.".
" END:VCARD";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文