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>
Alan Wells
  • 30,746
  • 15
  • 104
  • 152
  • Have you tried just using an HTTP GET Request to Facebook? No SDK? – Alan Wells Jul 10 '14 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. – Suhas Patil - SWTest Architect Jul 10 '14 at 18:23

2 Answers2

0

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

Zig Mandel
  • 19,571
  • 5
  • 26
  • 36
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?

Community
  • 1
  • 1
Alan Wells
  • 30,746
  • 15
  • 104
  • 152