【问题标题】:PHP: Twitter button doesn't show text + linkPHP:Twitter 按钮不显示文本+链接
【发布时间】:2013-01-10 16:36:58
【问题描述】:
这是生成的推特按钮,我在里面添加了文字。
> <iframe allowtransparency="true" frameborder="0" scrolling="no"
> src="http://platform.twitter.com/widgets/tweet_button.1357735024.html#_=1357817606773&count=horizontal&id=twitter-widget-0&lang=en&original_referer=&size=m&text=<?php
> echo $art["title"].'
> http://web.com/article.php?art_id='.$art["id"];?>&url=<?php
> echo
> 'http://web.com/article.php?art_id='.$art[id];?>&via=MyWeb"
> class="twitter-share-button twitter-count-horizontal" style="width:
> 107px; height: 20px;" title="Twitter Tweet Button"
> data-twttr-rendered="true"></iframe>
问题是,我无法在推文中添加链接。当我在那里添加它时,即使是简单的文本也没有显示。
有没有类似的问题或帮助,如何解决?
谢谢
【问题讨论】:
标签:
php
twitter
hyperlink
share
【解决方案1】:
我会稍微重新组织一下您的代码,以使 iframe src 的构建更易于遵循(那里可能存在错误)。您还应该确保 $art['title'] 是 urlencoded。
<?php
$iframe_src = 'http://platform.twitter.com/widgets/tweet_button.1357735024.html#_=1357817606773&count=horizontal&id=twitter-widget-0&lang=en&original_referer=&size=m&text=';
$iframe_src .= urlencode($art['title']);
$iframe_src .= 'http://web.com/article.php?art_id='.$art['id'];
$iframe_src .= '&url=http://web.com/article.php?art_id='.$art['id'].'&via=MyWeb';
?>
<iframe allowtransparency="true" frameborder="0" scrolling="no" src="<?php echo $iframe_src; ?>"
class="twitter-share-button twitter-count-horizontal"
style="width:107px; height: 20px;" title="Twitter Tweet Button"
data-twttr-rendered="true"></iframe>