The original script from Facebook developer page is as follows;
<div id=”fb-root”></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = “//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.9&appId=630535786999761”;
fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, ‘facebook-jssdk’));</script>
After pasting the script into the template and saving it, you will see this error “Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly. XML error message: The reference to entity “version” must end with the ‘;’ delimiter. OR you will get this error, “Your template could not be parsed as it is not well-formed.
Please make sure all XML elements are closed properly. XML error message: The entity name must immediately follow the ‘&’ in the entity reference”. So to correct this error you should not use “&” as a character in blogger templates when adding scripts but replace “&” to & tag. When using ampersand within an attribute value it should always be written using amp; tag.
Facebook Modified Script 2.3 – Have an App ID
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=536279186383983";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
You should replace the “536279186383983” to your appId.
Add this script to above “< / head >” (without spaces) tag. You can find it by CTRL+F and typting this tag on blogger template.
To know more about parsing xml, you can check out my new post of parsing xml error messages in blogger templates.
Update on New Facebook Modified Script 2.9 – Have an App ID
<script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=630535786999761"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>
Update on New Facebook Modified Script 2.9 – No App ID
If you do not have an app ID, copy the following code.
<div id=’fb-root’/>
<script>
/* <![CDATA[ */
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = “//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.9”;
fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, ‘facebook-jssdk’));
/* ]]> */
</script>
Check for Other XML Validation Errors
If you want to check for other XML validation errors, go to Online XML Syntax Error Parsing Validator Tool
Subscribe and Follow us if this works.