in Tips and Tricks

Linkify url and hashtag for linkedin Status and share api

IF you are working with linkedin api and parsing status and share items for any user or company page then this small code will help to parse the status or share text (comes from api) to 1. linkify 2. Tagging 3. Linkify hashtag
Please note that linkedin doesn’t support any native @ handle for it’s own user based but all @ handle are for twitter user.
[code language=”php”]
* Linkify url and hashtag
* @param type string $status_text
* @return type string
function linkify_linkedin_status($status_text){

// linkify URLs
$status_text = preg_replace(
‘<a href="\1">\1</a>’,

// linkify twitter users
//please note that any thing tagged using @ in linkedin takes to twitter
$status_text = preg_replace(
‘\1@<a target="_blank" href="\2">\2</a>’,

// linkify hash tags
$status_text = preg_replace(
‘\1#<a target="_blank" href="\2">\2</a>’,

return $status_text;