1

I want to use web share api, so i can share specific image coming from google spreadsheet with text and description, but unfortunatelly only image is being shared to facebook. The text, title and url it's missing. For whatsapp if working fine for example. Can anyone give hand for this? Thanks

Code below:

`

async function share() {
  const imageQuote = '<?=$image_quote; ?>';
  const response = await fetch(imageQuote);
  const blob = await response.blob();

  let pageTitle = 'THe Page';
  let pageText  = document.getElementsByClassName("quote")[0].innerText;
  let pageUrl   = window.location.href; 
    
  const filesArray = [
    new File(
      [blob],
      'panion.jpg',
      {
        type: blob.type,
        lastModified: new Date().getTime()
      }
   )
  ];
  const shareData = {
    title: pageTitle,
    text: pageText,
    url: pageUrl,
    files: filesArray,
};
  if (navigator.share) {
  navigator
    .share(shareData)
    .then(() => console.log("Successful share"))
    .catch((error) => console.log("Error sharing", error));
} else {
  console.error("Browser doesn't support Web Share API");
}
    console.log(shareData);
}
    
function shareThisQuote() {
    return share();
}

`

  • 2
    Does this answer your question? [Share API does not share message with Facebook](https://stackoverflow.com/questions/45261543/share-api-does-not-share-message-with-facebook) – asportnoy Oct 27 '22 at 15:52
  • @asportnoy Thx for the answer. Unfortunately this not answer my question, because I think this should be possible with Web Share API, but maybe facebook policy block text. – Vladimir Kyatipov Oct 27 '22 at 15:55
  • As that question explains, it is not possible due to Facebook's intentional limitations. – asportnoy Oct 28 '22 at 16:37
  • Is there another alternative, maybe like using og tags?.. just wondering. – Vladimir Kyatipov Oct 28 '22 at 18:14
  • 1
    Sure, share a URL that returns the desired data for those OG tags. – CBroe Nov 01 '22 at 08:17

0 Answers0