How do I check if it’s a Facebook robot?

Asked

Viewed 115 times

1

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

1 answer

2


According to this reply of the Gringo SO:

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 this here but these two are the most used.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.