【问题标题】:Use Twitter linkify in PHP posts在 PHP 帖子中使用 Twitter linkify
【发布时间】:2012-01-21 18:08:02
【问题描述】:

我对 PHP 和 JavaScript 非常陌生,我制作了一个 PHP 发布脚本,我想将 twitter 链接添加到用户名。我把javascript放在了头上,但没有运气。我遵循了所有的指示,但我无法让它工作。这是我的 PHP:

<form align="center" method='post' action='add.php'>
    <p>Your status:</p>
    <textarea name='body' rows='5' cols='40' wrap=VIRTUAL></textarea>
    <p> What color is a banana? (lowercase) </p>
    <input type="text" class="blah" name="age" />
    <input align="center" type="submit" class="submit" value="Post" disabled="disabled"/>
</form>
<script type="text/javascript">
$('.blah').change(function() {
    $(".submit").attr('disabled', $(this).val() != "yellow");
}).change();
</script>
<?php
$posts = show_posts($_SESSION['userid']);
if (count($posts)){
?> 
<table class="imagetable">
    <table align="center" border='0' cellspacing='0' cellpadding='5' width='300'>
<?php
foreach ($posts as $key => $list){
    echo "<tr valign='middle'>\n";
    echo "<td>".$list['body'] ."<br/>\n     "; 
    echo "<small>".$list['stamp'] ."</small><hr></td>\n"; 
    echo "</tr>\n"; 
}
?>
    </table>
<?php
}else{
?>
    <p><b>You haven't posted anything yet!</b></p>
<?php
}
?>
</body>
</html>

这是在&lt;head&gt;:

<script type="text/javascript">
twttr.anywhere(function (T) {
    T.linkifyUsers();
});
</script>

那么有人输入“Hi @stackoverflow”@stackoverflow 会链接到 Twitter 个人资料页面吗?

【问题讨论】:

    标签: php javascript twitter linkify


    【解决方案1】:

    欢迎使用 PHP!

    在使用之前,您需要将 Twitter JavaScript 库包含到您的页面中。

    像这样:

    <script src="http://platform.twitter.com/anywhere.js?id=YOUR_API_KEY&v=1" type="text/javascript"></script>
    
    • 请参阅this 页面了解如何获取 API 密钥。
    • 请参阅this 页面以了解有关任何地方的更多信息。

    【讨论】:

      猜你喜欢
      • 2011-01-17
      • 1970-01-01
      • 2018-07-01
      • 2012-03-22
      • 1970-01-01
      • 2012-03-03
      • 2014-08-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多