Facebook “Add Page Tag Dialog ” Workaround

Hallo zusammen,
für alle die aktuell den Bug haben: FB-Bug “Add Page Tag Dialog “
Hier mein kleiner Workaround um die App auf die Seite zu bringen.

Voraussetzung:
+ Rechte auf der Seite
+ App-Admin
+ Facebook-SDK (Javascript) geladen

Hello everybody,
at the moment i can’t add an app to a page with the “add page tag dialog” on facebook. FB-Bug “Add Page Tag Dialog “.
This is my workaround:

Prerequisite:
+ Right on the site
+ App Admin
+ Loading Facebook SDK (Javascript)

    function addAppToPage(name,appID){
        FB.login(function(response){
                FB.api('/me/accounts', function(response){
                    if (response && !response.error) {
                        $.each(response.data,function(k,v){
                            if(name.toLowerCase() == v.name.toLowerCase()){
                                FB.api(
                                    "/"+v.id+"/tabs",
                                    "POST",
                                    {
                                        "app_id": appID,
                                        "access_token": v.access_token
                                    },
                                    function (response) {
                                        if (response && !response.error) {
                                            console.log(response);
                                        }
                                    }
                                );
                            }
                        })
                    }
                })
            }
            ,{scope:"manage_pages"});
    }

    // 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/de_DE/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));

    // Die Funktion startet nach 2000ms
    setTimeout(function(){
        addAppToPage("YOURPAGE","APPID")
    },2000);

SocialMediaBar mit TypoScript

Wer wollte nicht schon immer mal für seine eigene Seite eine SocialMediaBar haben und auf jeder Seite Like’n / Google’n oder Twittern können…
hier mit dem kleinen TypoScript kann man das locker umsetzen.

Konstanten:
baseURL = http://www.domain.ltd/

Setup:
# **
# * socialmediabox
# ********************
lib.field_smb = COA
lib.field_smb {
  10 = TEXT
  10 {
    typolink.parameter.data = getIndpEnv:REQUEST_URI
    typolink.returnLast = url
    wrap (
    <li class="google">
    <div class="g-plusone" data-size="medium" data-href="{$baseURL}|"></div>
    <script type="text/javascript">
      (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();
    </script>
    </li>
    )
  }
  20 = TEXT
  20 {
    typolink.parameter.data = getIndpEnv:REQUEST_URI
    typolink.returnLast = url
    wrap (
    <li class="twitter"><a href="https://twitter.com/share" class="twitter-share-button" data-url="{$baseURL}|" data-size="medium">Tweet</a>
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
    </li>
  )
  }
  30 = TEXT
  30 {
    typolink.parameter.data = getIndpEnv:REQUEST_URI
    typolink.returnLast = url
    wrap (
    <li class="facebook"><div class="fb-like" data-href="{$baseURL}|" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>
    <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/de_DE/all.js#xfbml=1&appId=459667507386498";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
    </li>
    )
  }
 wrap = <ul class="smb">|</ul> 
}

Viel Spaß damit 😉