我使用SimpleXML通过RSS获取我的推文。我想在推文上点击链接。 但我不知道如何。我尝试了一些不起作用的东西。 需要您的帮助。如何在推特可点击的Twitter上创建链接RSS

这是我的代码;

<? 
$twitterRssFeedUrl = "https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=puzzletravel"; 
$twitterUsername = "puzzletravel"; 
$amountToShow = 5; 

$twitterPosts = false; 
$xml = @simplexml_load_file($twitterRssFeedUrl); 
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; 
$text = $xml; 
if(is_object($xml)){ 
    //Rest of our code will be here 
}else{ 
    die('cannot connect to twitter feed'); 
} 

foreach($xml->channel->item as $twit){ 
    if(is_array($twitterPosts) && count($twitterPosts)==$amountToShow){ 
     break; 
    } 
    $d['title'] = stripslashes(htmlentities($twit->title,ENT_QUOTES,'UTF-8')); 
    $description = stripslashes(htmlentities($twit->description,ENT_QUOTES,'UTF-8')); 
    if(strtolower(substr($description,0,strlen($twitterUsername))) == strtolower($twitterUsername)){ 
     $description = substr($description,strlen($twitterUsername)+1); 
    } 
    $d['description'] = $description; 
    $d['pubdate'] = strtotime($twit->pubDate); 
    $d['guid'] = stripslashes(htmlentities($twit->guid,ENT_QUOTES,'UTF-8')); 
    $d['link'] = stripslashes(htmlentities($twit->link,ENT_QUOTES,'UTF-8')); 
    $twitterPosts[]=$d; 
} 

if(is_array($twitterPosts)){ 
    echo '<ul>'; 
    foreach($twitterPosts as $post){ 
     echo '<li><p>'.$post['description'].'</p><p class="date">'.date(' j F',$post['pubdate']).'</p></li>'; 
    } 
    echo '</ul>'; 
}else{ 
    echo '<p>No Twitter posts have been made</p>'; 
} 

?> 

来源 2012-05-07 orko

+0 通过clickable,你的意思是,当用户点击该链接时,他会转到该页面。您可以通过使用''标签和'href'属性来做到这一点。 – vedarthk