Here is the Google Crawlers user agent:
FacebookExternalHit/1.1 FacebookExternalHit/1.0
or
facebookexternalhit/1.0 (+http://www.facebook.com/externalhit_uatext.php) facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
Please note that version numbers are subject to change. So use a regular expression to find the name of the crawler, and then display it.
Update :
You can use this code in PHP to check Facebook User Agent
if(preg_match('/^FacebookExternalHit\/.*?/i',$agent)){ print "Facebook User-Agent";
Here is the ASP.NET code. You can use this function to check if userAgent is a Facebook user agent.
public static bool IsFacebook(string userAgent) { userAgent = userAgent.ToLower(); return userAgent.Contains("facebookexternalhit"); }
Note:
Why do you need this? When you share a link to your site on Facebook, facebook looks at it and analyzes it to get some data to display a thumbnail, title and some content from its page, but it will link to your site.
In addition, I think that this will lead to a masking of the site, that is, the display of different data for the user and scanners. Cloaking is not considered good practice and may look for engines and a site to take note of.
Update . Facebook has also added a new user account since May 28, 2014.
Facebot
You can learn more about facebook finder at https://developers.facebook.com/docs/sharing/webmasters/crawler
Virendra Dec 24 '11 at 9:01 2011-12-24 21:01
source share