1

I have a Google apps script based web app. I want to add a Facebook plugin to it to have "Like" feature. The Facebook code is trivial to implement in a regular non-Google apps web page but I am having trouble integrating it in web app as the Caja compiler mangles the div id "fb-root" and as a result no "Like" button shows up on my page. See the plugin code below.

Has anybody managed to make this work? I have searched quite extensively and found an example of embedding javascript but no method to embed HTML that does not get mangled.

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

<div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/"></div>
2
  • Have you tried just using an HTTP GET Request to Facebook? No SDK? Commented Jul 10, 2014 at 17:46
  • 1
    @SandyGood, No. I have not yet tried the HTTP GET. The credentials management through OAuth will be another area to research to make this work. I was hoping I could implement Like feature without too much research as I am running short on time. Commented Jul 10, 2014 at 18:23

2 Answers 2

0

Its not possible as you already discovered, because of caja.

Sign up to request clarification or add additional context in comments.

Comments

0

My apps script Application has a Facebook Login all done with urlFetch() HTTP Requests. You can't interact with Facebook through an SDK from Apps Script, but you CAN issue HTTP Requests to Facebook. The Facebook Developers site has information about this. You can issue GET requests to Facebook and receive a response.

Facebook Graph API

I'm not sure about the "Likes", but I have a Facebook Login set up on my Google Apps Script application.

See my answer here on StackOverflow:

Use the Facebook API in a Google Apps Script web app?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.