Biribu
Biribu

Reputation: 3833

Specify url in facebook share button sharer.php

I am trying to set a share button in my dynamically created webpage. I am using this code:

<a name="fb_share" type="button_count" share_url="TEXT" href="http://www.facebook.com/sharer.php?u="URL">Share</a>

But all I get is the original url plus my text "TEXT". I can't use the original url since it will not exists. It is just created for that moment every time. So I want to share a fixed url.

Is it possible? I haven't had any problem with google plus or twitter.

Upvotes: 0

Views: 5452

Answers (1)

Chexpir
Chexpir

Reputation: 1876

That code is deprecated.

If you want to share a URL different from the current one, that is not posible anymore.

You can get more info and current code in https://developers.facebook.com/docs/plugins/share-button/

Exactly, right after the

<body>

you should add

<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/es_ES/all.js#xfbml=1";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>

Adn then you have to add wherever you like the following:

<div class="fb-share-button" data-href="http://developers.facebook.com/docs/plugins/" data-type="button_count">
</div>

Upvotes: 1

Related Questions