Question

When i try to share the blog content in one of my website into facebook Wrong content and image comes out.But the correct content is popup on sharer.php page. But the content shared on the facebook is wrong. It shares some other content and image from the blog page. I added

<meta property="og:title" content="<?php echo $usethistitle; ?>" />
    <meta property="og:type" content="website" />
    <meta property="og:url" content="http://taralizhealthystepsforward.com/blog.php?blogid=<?php echo $blogid; ?>" />
    <meta property="og:image" content="http://taralizhealthystepsforward.com/pdt_images/<?php echo $imges; ?>" />
    <meta property="og:site_name" content="Taraliz" />
    <meta property="og:app_id" content="563087643750661" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="image_src" href="http://taralizhealthystepsforward.com/pdt_images/<?php echo $imges; ?>" />



<script>window.location='https://www.facebook.com/sharer/sharer.php?s=100&p[url]=http://taralizhealthystepsforward.com/blog.php?blogid=<?php echo $blogid; ?>&p[images][0]=http://taralizhealthystepsforward.com/pdt_images/<?php echo $imges; ?>&p[title]=<?php echo $usethistitle; ?>&p[summary]=<?php echo $usethisdesc; ?>';</script>

Website: http://taralizhealthystepsforward.com/blog.php

Was it helpful?

Solution

Sharer uses parameters from the URL to display in the window, but when the content is shared it goes to a link specified.

Since your posts are on the same HTML page, a page uses one and the same opengraph data, that is <meta> tags with og properties.

What you could do is create an endpoint for facebook shares, where only a metadata information would be fetched. Say, meta.php?id=[:id] that will supply facebook with information per post and also inform it to redirect to a correct page and scroll, perhaps with # and identifier.

I don't think that you can use different attributes for facebook to display with one page using sharer.php file, however I will research and update my answer if I find anything worth considering.

UPDATE

I don't think you can solve your problem without writing an additional code. Here is your question asked with different words Multiple Facebook opengraph objects on the same page

That answer suggests a better solution than mine, instead of creating a new endpoint file like meta.php you could do this in the very same file you use to display your blog content. This is done by checking an User agent, which if is Facebook related you will show specific meta og tags.

Excerpt from linked answer by Simon Cross $_SERVER["HTTP_USER_AGENT"] != "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top