How can I check if it's a facebook robot?

1

Is there any way, with PHP, to check if the server access is being done by a bot / facebook bot?

    
asked by anonymous 14.01.2017 / 21:17

1 answer

2

According to this gringo OS answer :

if (
    strpos($_SERVER["HTTP_USER_AGENT"], "facebookexternalhit/") !== false ||          
    strpos($_SERVER["HTTP_USER_AGENT"], "Facebot") !== false
) {
    // é provavelmente um bot do facebook
}
else {
    // nao eh um bot Facebook
}

The complete list is here but these two are the most used.

    
14.01.2017 / 23:24