我只是想分享我们的成功,因为我无法在任何地方找到这些信息(全部是在PHP中)
使用.NET库,AJAX& Javascript,我的同事正在运行twitter API 1.1,但它没有可点击的URL,@ mentions或#hashtags。
答案 0 :(得分:-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>");
}