Search code examples
imageweb-crawlermeta-tagsfacebook-opengraph

OG:IMAGE meta property of Facebook URL giving Bad URL timestamp


I am making api to generate link previews when sharing from app. I first try to get og:image meta property then try for img tags.

Please suggest any solution to get a preview image from facebook URL

  1. Open link of facebook url in incognito tab (og:image doesn't appear if logged in) e.g
https://www.facebook.com/photo.php?fbid=10156532336573106&set=a.10150325145123106&type=3&eid=ARA8J7aPjJ9TMOLIhsxoU-IEDydSAIDowKzHAKb5TLidsVUz3GFNkIQY6_g4uyQ1_OhtMJO0GAq9JgHl
  1. View Source of Page
  2. Find "og:image" meta property
  3. copy content value and open in new tab e.g
https://scontent.fkhi10-1.fna.fbcdn.net/v/t1.0-9/68693440_10156532336578106_7081557032720924672_n.jpg?_nc_cat=107&amp;_nc_oc=AQkyK966KxqYD7G0m1EtR-8w8y69sV8QaPbA9_r2DHMm5wSQLlaUzBrlRYW-WMG7uic&amp;_nc_ht=scontent.fkhi10-1.fna&amp;oh=45473e68efe2df33d683c28a5441674f&amp;oe=5DE19A38" /><meta property="og:url" content="https://www.facebook.com/nauman.akbar/posts/10156532339213106

Bad URL timestamp appears. Error appears on fresh links also, doesn't appear to be time related


Solution

  • its all because the url have some special characters please decode it. use this

    System.Net.WebUtility.HtmlDecode()