user1433490
user1433490

Reputation: 13

Facebook Share button - Scraper doesn't fetch meta tags

I've been working on this page http://www.btselem.org/hebrew/131606

I decided to add the Facebook Share button, but for some reason whenever I try sharing, the Facebook scraper doesn't manage to get any of the meta tags in the source – it only displays the site's URL. After checking the URL in the facebook developers debugging tool, I got a 206 response code and the following error:

Can’t download - Could not retrieve data form URL.

I also checked the "See exactly what our scraper sees from your URL" option, and it seems the scraper only manages to read out the following line:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

The weird thing is that this isn't even the DOCTYPE I've got in the page's source. I already tried changing the DOCTYPE to:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

After I read some older posts saying this should fix the problem, but that doesn't work either – I keep on getting the same line from the scraper. I'll be thankful for any tip or idea you guys have…

I posted the first part of the source, at least the part containing the meta tags. I'll add the whole code if necessary. Thanks in advance,

David.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/" xml:lang="he" lang="he" dir="rtl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>לקסיקון הכיבוש: 67 שניות על... מאחז |בצלם</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta property="fb:app_id" content="142675212478057"/>

<link rel="shortcut icon" href="/sites/all/themes/btselem/images/favicon.ico" type="image/x-icon" />
<meta property="og:site_name" content="בצלם" />
<meta property="og:title" content="מאחז | בצלם" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://www.btselem.org/hebrew/131606" />
  <link type="text/css" rel="stylesheet" media="all" href="/sites/default/files2/css/css_1458508373fb743060ffb80b43b3d59c.css" />
<link type="text/css" rel="stylesheet" media="print" href="/sites/default/files2/css/css_ff9c22380c0853814b0563da89e16090.css" />

Upvotes: 1

Views: 4255

Answers (3)

Dinko Tontchev
Dinko Tontchev

Reputation: 21

I had this exact issue just now when trying to have the Facebook Scraper ( https://developers.facebook.com/tools/debug) read an Object Graph file I created. When I had white space (spaces) before my "<meta property=..." the scraper showed that it was seeing my meta as part of the body tag and not the head tag which was the case. When i removed the white space before my meta tags, the scraper could correctly see the meta tags in the head and it worked well. For the sake of curiosity I replaced my previous 4 space width white space with tabs and the scraper was able to correctly see the content. Very strange. Hope this helps someone!

Upvotes: 2

DMCS
DMCS

Reputation: 31870

Looks like you're trying to put meta tags into your <body> tag.

http://developers.facebook.com/tools/debug/og/echo?q=http%3A%2F%2Fwww.btselem.org%2Fhebrew%2F131606

<!DOCTYPE html>
<html>
<body>
<p>UBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;</p>
<meta http-equiv="content-type" content="text/html; charset=utf-8">

This isn't well formed HTML. Fix up the HTML issues and then Facebook should be able to lint your page correctly.

Upvotes: 0

cpilko
cpilko

Reputation: 11852

When I look at the generated source of your document, there is a blank line that appears before your <!DOCTYPE> tag.

The 206 response code usually indicates that the requester has cancelled the transmission. It may be the blank line is confusing the Facebook parser and it's just giving up.

I haven't worked with Drupal much, but in other PHP based CMS systems, this usually occurs because there is whitespace between a closing ?> tag and the EOF marker in a php file that is called before the header renders. It seems to be agreed that omitting these closing php tags wherever possible is a best practice.

Before you go through the process of editing all your PHP files, you could test this by copying the source for this page and saving it as a static html file on your sever without the whitespace. See if that will get parsed by the Facebook debugger. If it doesn't, then you've got another problem.

Upvotes: 0

Related Questions