0

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);
Abraham
  • 3
  • 5
  • Possible duplicate of [Facebook like - showing cached version og:image, way to refresh or reindex it?](https://stackoverflow.com/questions/7572441/facebook-like-showing-cached-version-ogimage-way-to-refresh-or-reindex-it) – Obsidian Age Feb 08 '18 at 21:32
  • Graph API calls needs some form of client secret and access token to work. – floverdevel Feb 08 '18 at 21:42
  • I pased my ID and secret key like that: https://graph.facebook.com/endpoint?key=value&access_token=app_id|app_secret and still ERROR. – Abraham Feb 08 '18 at 22:51
  • you say "error", but why do you not say WHAT error exactly? – andyrandy Feb 09 '18 at 07:48

1 Answers1

0
<script src="//connect.facebook.net/en_US/sdk.js"></script>
<script>
function reloadLink(){
FB.api('https://graph.facebook.com/','post',  {
        id: {{URL}},
        scrape: true,
        access_token:{{ACCESSTOKEN}}
    }, function(res) {


    });
}
</script>
twitch
  • 225
  • 1
  • 13