The following code is for the built in Facebook sharer URL construction in Magento's 1.9 RWD theme.
<li>
<?php $_u = 'p[url]=' . $_productUrl . '&p[images][0]=' . $_productImageUrl . '&p[title]=' . $_productName . '&p[summary]=' . urlencode(trim($_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description'))); ?>
<a href="<?php echo 'http://www.facebook.com/sharer.php?s=100&' . $_u; ?>" target="_blank" title="<?php echo $this->__('Share on Facebook') ?>" class="link-facebook">
<?php echo $this->__('Share Facebook') ?>
</a>
</li>
When sharing a URL though with this Facebook button, the description for the page is including HTML tags. Not only have I tried to strip_tags
for the short description, it is actually using the long description even if I replace short description with another attribute. I can't find anything in Mage_Core for this…
It is changing the URL correctly for the &p[summary]=
parameter but when you preview the shared URL, it just shows the description along with HTML tags.
Any ideas on how to fix this?
Best Answer
Source: https://developers.facebook.com/x/bugs/357750474364812/
The URL is the only possible parameter:
Just make sure the Open Graph Tags are correct: http://ogp.me/
Btw, you can also use the Share Button or the Share Dialog, but they don't accept custom parameters either: https://stackoverflow.com/questions/24322221/passing-title-url-and-image-on-share-php-of-facebook
If it does not pick up the correct OG tags, make sure to check out the URL in the Facebook debugger, you can also refresh the tags with it - because they will get cached by Facebook: https://developers.facebook.com/tools/debug/
IMPORTANT: The URL MUST be public, Facebook needs to be able to scrape it!