【问题标题】:Creating Clickable Links in Twitter API 1.1 Javascript在 Twitter API 1.1 Javascript 中创建可点击链接
【发布时间】:2013-06-27 22:06:26
【问题描述】:

我只是想分享我们的成功,因为我在任何地方都找不到此信息(全部在 PHP 中)

使用 .NET 库、AJAX 和 Javascript,我的同事运行了 twitter API 1.1,但它没有可点击的 URL、@mentions 或 #hashtags。

【问题讨论】:

    标签: javascript url twitter hashtag


    【解决方案1】:

    解决办法如下:

    function replaceAtMentionsWithLinks(text) { 
                    var exp = /@([a-z\d_]+)/ig; 
                    return text.replace(exp, "<a href='http://twitter.com/$1' 
                        <http://twitter.com/%241%27> @$1</a>"); 
                    } 
            function replaceURLWithHTMLLinks(text) {
                    var exp = /(\b(www\.|http\:\/\/)\S+\b)/ig;
                    return text.replace(exp,"<a href='$1'>$1</a>"); 
                    }
            function replacehashtags(text) {
                    var exp = /\#(\w+)/ig;
                    return text.replace(exp, "<a target='_blank' 
                    href='https://twitter.com/search?q=%23$1&src=hash'>#$1</a>");
                    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-31
      • 2011-02-01
      • 2014-03-04
      • 1970-01-01
      • 2020-06-28
      • 2012-01-24
      • 2010-11-18
      相关资源
      最近更新 更多