Posts Tagged ‘social networking’

I’ve discovered a huge drawback to the Twitter messaging system: it does not store links. The Twitter site itself will identify URL’s in messages and convert them into clickable links for you automatically. But the magic ends at Twitter’s borders; anyone who wants to do the same on their site is on their own.

So I consulted the almighty Google. I found plenty of raw regex, javascript, and Twitter-focused discussions on the matter, but I found the offered solutions and tips lacking. I wanted to do this up right, transparently via PHP in the background. No JS required.

Finally, I found a small PHP script that accomplished what I needed. Here’s a renamed version—all code intact—that will find and convert any well-formed URL into a clickable <a> tag link.

function linkify( $text ) {
  $text = preg_replace( '/(?!<\S)(\w+:\/\/[^<>\s]+\w)(?!\S)/i', '<a href="$1" target="_blank">$1</a>', $text );
  $text = preg_replace( '/(?!<\S)#(\w+\w)(?!\S)/i', '<a href="http://twitter.com/search?q=#$1" target="_blank">#$1</a>', $text );
  $text = preg_replace( '/(?!<\S)@(\w+\w)(?!\S)/i', '@<a href="http://twitter.com/$1" target="_blank">$1</a>', $text );
  return $text;
}

Copy that into your code, then run your text containing unlinked URL’s through it. :

    <li><?php echo linkify($status->text) . '<br />' . $time_display; ?></li>

Facebook announced a revamp of its user privacy controls, responding to widespread public criticism following its f8 conference product launches with systematic changes that it said came out of weeks of nights-and-weekend work by its top engineers and designers. Facebook CEO Mark Zuckerberg called the release a “modern privacy system” that reflects what the site has become and incorporates feedback from users.

(more…)

Social network Facebook has said it will offer a one-stop shop for privacy settings in response to user concerns.

Facebook founder Mark Zuckerberg admitted the settings had “gotten complex” for users.

It follows a storm of protest from users over a series of changes on the site that left its members unsure about how public their information had become. (more…)