mercredi 25 février 2015

Clear Facebook Meta data instantly

I have a share functionality on my site, the meta data is built dynamically from the model the problem I have the user can make a combination of ingredients and then click share with friends, clicking this button takes them to a thank you page where the combination they have created is displayed, and the meta data is created by appending the image name and the image title using



@Model.ImageCombintation
@Model.ImageTitle


My controller looks like this



public ActionResult ThankYou()
{
var model = (LabCombination)Session["Comb"];

return View(model)
}


Inside LabCombination consists of the image, title and other additional information.


I built the meta data like this appending the @Model details to the end and it gets rendered as follows:



<meta property="og:title" content="Check out the flavour I just made! Blackcherry &amp; Cinnamon" />
<meta property="og:description" content="Check out the flavour I have just created!" />
<meta property="og:image" content="http://ift.tt/18mTvQy" />
<meta property="og:url" content="http://ift.tt/1FqcwLU" />


This works fine for the first time round, but when I go back to the page and create another combination and click share with friends the meta data is updated yet the share dialog shows the previous combination as shown here for an example, the image you see in the middle is the new combination where as the image in the share dialog pop up is the previous image.


enter image description here


Now I have googled this and many people have suggested using http://ift.tt/1sbmVox and scrapping the page again, that's fine but its pointless when this site is live as many people are creating different combinations I need the affect to be instant not sit around waiting for it to reflect new images! and nor will I be scrapping the page again.... how can I get around this?


Update


After reading whats on the intenet alot of people are saying if you need to update the content on the share functionality then you need to resubmit the object with the 'scrape' parameter set to 'true' in your POST request. Below is what I have on the bottom of my page



<script>
$(document).ready(function () {
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
});
</script>


Where would I put that?


Aucun commentaire:

Enregistrer un commentaire