Facebook Share Story Image Does Not Appear For First time

≯℡__Kan透↙ 提交于 2019-11-26 18:35:58

问题


I try to share the article or web page but the story does not show the image when sharing for the first time but when i share for the next time, image is coming.

Checked in FB Debugger Also, same result.image not coming for the first time , next time it is coming.

<html class="no-js" lang="ar" dir="rtl" data-ng-app="mApp" xmlns:fb="http://ogp.me/ns/fb#">
<meta property="og:title" content="mytitle"/>
<meta property="og:url" content="http://mytest.com"/>
<meta property="og:image" content="http://mytest.com/1-773128.jpg"/>
<meta property="og:description" content="ffff2024"/>
<meta property="og:site_name" content="ggggggg"/>
<meta property="og:type" content="ARTICLE"/>
<meta property="fb:app_id" content="2444444444444"/>

回答1:


https://developers.facebook.com/docs/sharing/best-practices#precaching lists ways to avoid this problem, by either

  • scraping new articles upfront via API, or

  • specifying the image dimensions via OG meta tags as well.




回答2:


UPDATE

This solution with iframe is not working anymore! Worked since yesterday 06 February 2017. Facebook just set X-Frame-Options as DENY so you cannot load the sharer url in an iFrame. I'm figuring out another workaround.


I struggled to find a solution for this facebook bug (adding og:image:width and og:image:height was not enough).

Finally I came up with a workaround that worked: I added an hidden iFrame with the sharer link in the page footer; in this way the facebook crawler check the page once is loaded and, when you click facebbok share button in the first time you can see the shared image!

Example:

<iframe style="width: 0px; height: 0px; margin: 0px; padding: 0px;" src="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.example.com"></iframe>


来源:https://stackoverflow.com/questions/32505477/facebook-share-story-image-does-not-appear-for-first-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!