Error parsing XML, line 337, column 62: The reference to entity "appId" must end with the ';' delimiter [duplicate]

StackOverflow https://stackoverflow.com/questions/23584388

Question

Am trying to add facebook login to my website using javascript SDK.

    <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&appId=1502856099942926&version=v2.0";
  fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    </script>

When I add the above code and save it to my website code, am getting the error: Error parsing XML, line 337, column 62: The reference to entity "appId" must end with the ';' delimiter.

How to get rid of this error?

Was it helpful?

Solution

Try this

<script>
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src =     &quot;//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;appId=1502856099942926&amp;version=v2.0&quot;;
  fjs.parentNode.insertBefore(js, fjs);
    }(document, &#039;script&#039;, &#039;facebook-jssdk&#039;));
</script>

OTHER TIPS

Try to replace the & characters in the url with & and see if that makes a difference.

Add the following code before your code

window.fbAsyncInit = function() {
    FB.init({
      appId      : 'your-app-id', // App ID
      status     : true, // login status
      xfbml      : true  // parse XFBML          
      cookie     : true, // enable cookies

    });
  };

Hope this helps!

instead of put all in a single expression like this:

js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=1502856099942926&version=v2.0";

use FB.init function so you will not have any problems with the quots.

just put your own configuration like this:

<!-- facebook -->
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
    FB.init({
      appId      : 'YOU_APP_ID', // App ID
      xfbml      : true, // parse XFBML
      version    : 'v2.0' // sdk version           
    });
    // Additional initialization code here
  };
  // Load the SDK Asynchronously
  (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";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>
<!-- /facebook -->

Reference (for more info in details): https://developers.facebook.com/docs/javascript/quickstart/v2.0

If you are using blogger then use a Blogger HTML Converter. It worked for me with the recommendation feed of fb. ex original:

    <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&appId=[APP ID]&version=v2.0";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

ex after translation:

&lt;div id=&quot;fb-root&quot;&gt;&lt;/div&gt;
&lt;script&gt;(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 = &quot;//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;appId=[APP ID]&amp;version=v2.0&quot;;
  fjs.parentNode.insertBefore(js, fjs);
}(document, &#039;script&#039;, &#039;facebook-jssdk&#039;));&lt;/script&gt;

Its so simple dear. The problem is that you are selecting HTML5 while generating facebook app on facebook. Just Click on "IFRAME" and your problem is solved. :) See screenshot for more. here is screenshot

Try this:

//<![CDATA[
paste your plugin code here
//]]>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top