When i share an article from my site with Facebook sharer I have a problem with cache, For example- if I edit the title or image of that article and share it, Facebook still share the old content. I know this site: https://developers.facebook.com/tools/debug/ but of course I need to make it automaticlly.. So I tried to build sometihng with JavaScript/JQuery,Like a function that get a URL and put it into this API, when do I call this function? right after I press save button in my CMS (mean that I made a change in the article).
This is the code I used and It's not working,can anyone help me with this?
var url= "URL";
function ClearSharerCache (url) {
//https://graph.facebook.com/endpoint?key=value&access_token=app_id|app_secret
$.ajax({
type: 'POST',
url: 'https://graph.facebook.com?id='+url+'&scrape=true',
success: function(data){
console.log(data);
}
});
}
ClearSharerCache(url);