I have a webpage (in Drupal 6) which contains a Facebook like button, a comment box like. The Facebook receives through open graph tags the information which has to be shared. This site is not accessible for anonymous users, only for registered users.
When an anonymous user tries to open the site, he's redirected to the log in page. Here comes the problem: when Facebook scans the page to receive the information which should be shared, the site handles as anonymous user and redirects to the log in page. So the Facebook receives the log in page's information (image, description). Can I decide/verify somehow when the Facebook is trying to scan my site to avoid to redirect it to the log in page (somehow without Facebook API)?
You can get the list of Facebook IPs (List of IP Space used by Facebook) and let them bypass Drupal's authentication.
Another option is to override the description, image and title (see: Want custom title / image / description in facebook share link from a flash app).
Another option is to have an extra parameter, like fb=1
and generate the necessary tags for facebook to parse, that include the image, short description and title without any authentication required. Append fb=1
to your share links then. The facebookexternalhit/1.1 (+http: //www.facebook.com/externalhit_uatext.php)
user-agent can also be sensed instead when generating share snippets (thanks @madebydavid). But be careful not to show or authenticate the user, since anyone can set the user-agent header or append fb=1
to your URL.
Stay safe.