Facebook Open Graph API - og:metatags being ignored
Asked Answered
M

4

8

I'm troubleshooting an issue where the page title and image aren't being included on facebook likes. Having hit the OG debugger, it looks like none of the og:metatags are being accessed by facebook:

Here's a link to the debugger — it's saying it is inferring the og:url and og:title properties which are present on the page.

As a matter of testing, I copied the metatags and HTML schema straight from the example on the developer docs and I still get the same warnings.

Here's the HTML and start of the head tag as generated:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle</title>
<meta name="description" content="Transactiv Products" />
<meta name="title" content="Transactiv" />
<meta property="fb:app_id" content="289501899130" />
<meta property="og:site_name" content="Transactiv InRecv" />
<meta property="og:url" content="http://localhost:2609/Pages/ProductSummary.aspx?OrganizationProductID=617c54a0-189a-48af-9b5e-002148210208&StoreID=a1d6bc99-9a6a-4e46-bdb4-790be4e59bd4&ProductID=d6748a89-41f4-48aa-a1c1-5c28f87cc47f&PageName=MHMTest&PageID=236549899706529" />
<meta property="og:title" content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" />
<meta property="og:type" content="website" />
<meta property="og:description" content="" />
<meta property="og:image" content="http://transactivazureprod.blob.core.windows.net/pictureblob/831a4d4a-dbe3-44f5-9ff8-12286cdc33f5" />

Any ideas on this?

Mislay answered 3/11, 2011 at 18:22 Comment(0)
L
6

Facebook reads all properties you can enter your url here: https://developers.facebook.com/tools/debug

Facebook will read the properties you specified, but sometimes will use them only when all 4 are specfied (and not empty), not only the last 3.

<meta property="og:url" content="YOUR_URL" />
<meta property="og:title" content="YOUR_TITLE" />
<meta property="og:description" content="YOUR_DESCRIPTION" />
<meta property="og:image" content="YOUR_IMAGE" />
Limonene answered 20/10, 2012 at 7:53 Comment(0)
G
5

Obvious flaw. You don't propely end the title. You got " in it.

I'd suggest doing a str_replace('"', "''", $str) before echo'ing it.

That is,

<meta property="og:title" content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" />

to

<meta property="og:title" content="123-ABC Butterfly Fun Carpet 3'10'' x 5'5'' Rectangle" />

EDIT:

You can also consider doing htmlentities($str, ENT_QUOTES), as suggested by @TwoWholeWorms,

Georginegeorglana answered 3/11, 2011 at 18:25 Comment(7)
You're totally right there - something to fix - however, even when I don't have that issue, facebook still ignores the metatags - I also pulled the values straight from the open graph docs example and they give me the same warnings:Mislay
And you're trying with the Linter?Georginegeorglana
Yeah - the linter is telling me that it's inferring those "required" properties even though they are on the pageMislay
Good thought - but same problem.Mislay
The crazy thing that I'm not following is that the facebook scraper is missing jsut about everything in my <head> tag. developers.facebook.com/tools/debug/og/…Mislay
This problem wasn't on the facebook end. An error page was being served up to the facebook crawler as we were requiring authentication to serve this page. Thanks for your help guys :)Mislay
You'd be better off doing htmlentities($str, ENT_QUOTES) rather than str_replace. There's more characters which will break the parser than just ".Bohunk
P
1

Facebook's scraper is seeing an error page when it tries to visit your site.

You can access the Facebook scraper's view of your pages through the link 'See exactly what our scraper sees' at the bottom of the debug page.

Also it doesn't just seem to be a scraper related problem as I'm also seeing the same message when I visit the link: http://transactivstaging.cloudapp.net:8080/Pages/ProductSummary.aspx?OrganizationProductID=617c54a0-189a-48af-9b5e-002148210208&StoreID=a1d6bc99-9a6a-4e46-bdb4-790be4e59bd4&ProductID=d6748a89-41f4-48aa-a1c1-5c28f87cc47f&FBUserId=100002152993326&PageName=MHMTest&PageID=236549899706529&CurrentPage=0

ShoppingCart.GetShoppingCartItems.Failed If this Error persists, you can contact our support and provide the following Error Id as a reference
Pistole answered 3/11, 2011 at 22:0 Comment(0)
R
0

I would guess that, as well as the " in the title values mentioned by Robin Castlin (which you could also escape as &quot;), that your og:url contains unescaped ampersands.

Does it work if you replace & with &amp; in that og:url field?

So you'd replace

<meta property="og:title"
  content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" />
<meta property="og:url"
  content="http://localhost:2609/Pages/ProductSummary.aspx?
  OrganizationProductID= ... &StoreID= ..." />

to

<meta property="og:title"
   content="123-ABC Butterfly Fun Carpet 3'10&quot; x 5'5&quot; Rectangle" />

<meta property="og:url"
  content="http://localhost:2609/Pages/ProductSummary.aspx?
  OrganizationProductID= ... &amp;StoreID= ..." />

to make sure the metadata all contains valid HTML.

Ritualism answered 30/1, 2012 at 12:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.