dragon071111 2013-12-02 11:02
浏览 174
已采纳

如何检测Facebook连接以避免重定向?

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)?

  • 写回答

1条回答 默认 最新

  • dongya2029 2013-12-02 14:16
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测