0

I want to create Twitter and Facebook share buttons. I only want create share links because I don't want to take the buttons they provide from their docs. For Twitter this was really easy because it only expects one url parameter

(I'm using VueJs so I can pass in variables)

<a :href="`https://twitter.com/intent/tweet?text=${shareText}`">Share</a>

where the shareText is just a property combining the page title and page url ${this.title} ${encodeURI(window.location.href)}. From the Facebook docs https://developers.facebook.com/docs/plugins/share-button/ I was not able to find information about how to create a share link without downloading Facebook packages.

How can I create the equivalent for Facebook?


Update

From the comments I took this link Facebook share link without JavaScript for more information. I think there is no way I can share a text with a link so I try to stick with the link only. This is what I have so far

<a :href="`https://www.facebook.com/sharer/sharer.php?u=${encodeURI(window.location.href)}`">Share</a>

In my application the generated sample link would look like

https://www.facebook.com/sharer/sharer.php?u=http://localhost:8080/users/1

When clicking on it the Facebook page opens up and shows this error message

enter image description here

So how can I fix it?

Question3r
  • 2,166
  • 19
  • 100
  • 200

0 Answers0