I am displaying some twitter feeds using simplepie but I have notice that a lot of the tweets have link in them so I can I make them 'clickable' URLs? To display the tweet I am using this code: <?php echo $item->get_title(); ?> Code (markup): I haven't been able to find a solution. Thanks in advance!
hmm, doesn't <?php echo "<a href='" . $item->get_title() . "'>" . $item->get_title() . "</a>"; ?> Code (markup): work at all?
that links the whole tweet to twitter, i want to link the urls that people post in the tweet, like something to tinyurl.com.
You would probably need to parse the tweet, look for http:// in the tweet, and if found, add tags to display the URL with <a href> tags. preg_replace would probably work here. I'm not familiar enough with regexp to make the actual pattern for recognizing the urls, but it would be something like this: $items = preg_replace("<pattern>","<pattern for replacement>",$item->get_title()); and then you could just use "$items" instead of $item->get_title() in your code
That got me enough info to get it to work. Although the link text only shows the mydomain.com and nothing else but it does link to the right URL. Here is the final code: <?php $items = preg_replace( '/(http|ftp)+(s)?:(\/\/)((\w|\.)+)(\/)?(\S+)?/i', '<a href="\0">\4</a>', $item->get_title()); echo $items; ?> Code (markup):