Share text on Facebook

2

I'm trying to share the text from my web to Facebook, I'm using AddThis to create the social networking buttons. It gives me this:

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
    <a class="addthis_button_preferred_1" addthis:url="http://www.planow.com.br/jrgrill/dicas.php?id='.$id.'" style="width:29px"></a>
    <a class="addthis_button_preferred_2"style="width:29px"></a>
    <a class="addthis_button_preferred_4"style="width:29px"></a>
</div>
<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5329d2273cb2c738"></script>
<!-- AddThis Button END -->

I'm trying to pass content by parameters, but I can not. How should I proceed?

    
asked by anonymous 19.03.2014 / 19:03

2 answers

5

In order to pass parameters or even set a specific URL, you have three ways to do this:

  • Specify the parameter for addThis in wrapper :

    <div class="addthis_toolbox addthis_default_style addthis_32x32_style"
         addthis:url="http://www.planow.com.br/jrgrill/dicas.php?id=1">
        <!-- ... -->
    </div>
    

    You added the parameter to the link, but it should be in div that contains the links.

  • In the configuration, you indicate the desired URL:

    <script type="text/javascript">
      var addthis_config = {
        url: "http://www.planow.com.br/jrgrill/dicas.php?id=1"
      };
    </script>
    
  • You use setAttribute() to set the addthis:url attribute to the URL you want to use:

    <div class="addthis_toolbox addthis_default_style addthis_32x32_style" id="minhaWrapper">
      <!-- ... -->
    </div>
    <script type="text/javascript">
      var addThisWrapper = document.getElementById("minhaWrapper");
      var meuURL = "http://www.planow.com.br/jrgrill/dicas.php?id=1";
      addThisWrapper.setAttribute("addthis:url", meuURL);
    </script>
    

Any of these methods can be used to tell addThis which URL and its parameters we want to use.

Link to the addThis documentation for Setting the URL to Share (English) .

    
19.03.2014 / 23:39
-1

An alternative is the citation plugin that lets people select texts on your page and attach them to their shares to tell a more interesting story. To use this plugin you do not need to implement Facebook login or request other permissions through the application review.

link

    
22.10.2018 / 07:27