Search code examples
facebookfacebook-graph-apifacebook-sharer

Adding text to a facebook share pop up (javascript not hardcoded html string)


I am trying to add text to a facebook share link after it pops up. I have looked through the facebook dev site and searched online and the only thing that looked like it might remotely work was adding in meta tags for the Graph API. But I couldn't get them to work or display anything.

Below is the code for the button

<script>
    function fbs_click() {
      u=location.href;
      t='Where is your kind of crowd? Ask StreetPotato';
      window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');

      return false;
    }
</script>

<a rel="nofollow" href="#" 
      class="fb_share_button social" onclick="return fbs_click()"
      target="_blank" 
      style="text-decoration:none;"
      title='Follow us on Facebook'>
      <%=image_tag "social/facebook.png", alt:"Follow us on Facebook"%>
</a>

If anyone has any insight or idea how to add in default text, like a hash-tag into the share text box it would be awesome. Thanks for reading.

-Alan


Solution

  • In general, you should not pre-populate any of the Facebook social dialogs that will post on behalf of a user.

    See IV.2 of the Platform Policy doc:

    "You must not pre-fill any of the fields associated with the following products, unless the user manually generated the content earlier in the workflow: Stream stories (user_message parameter for Facebook.streamPublish and FB.Connect.streamPublish, and message parameter for stream.publish), Photos (caption), Videos (description), Notes (title and content), Links (comment), and Jabber/XMPP"