I'm aware you can force update a page's cache by entering the URL on Facebook's debugger tool while been logged in as admin for that app/page: https://developers.facebook.com/tools/debug
But what I need is a way to automatically call an API endpoint or something from our internal app whenever somebody from our Sales department updates the main image of one of our pages. It is not an option to ask thousands of sales people to login as an admin and manually update a page's cache whenever they update one of our item's description or image.
We can't afford to wait 24 hours for Facebook to update its cache because we're getting daily complaints from our clients whenever they don't see a change showing up as soon as we change it on our side.
This is definitely the correct answer. POSTing /? id=<url>&scrape=true to graph.facebook.com will force a re-scrape of the og tags for hte url. One must remember that this must be a POST request, not a GET request, otherwise you just get the number of shares.
Look under “og:image” section of the content displayed. Chances are, your image is missing, there's no image there at all, or it's displaying an old image. In any of those cases, hit the blue “Fetch new scrape information”, and check again to see if the correct image is now displayed in the “og:image” section.
The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.
Page metadata isn't the sort of thing that should change very often, but you can manually clear the cache by going to Facebook's Debug Tool and entering the URL you want to scrape
There's also an API for doing this, which works for any OG object:
curl -X POST \ -F "id={object-url OR object-id}" \ -F "scrape=true" \ -F "access_token={your access token}" \ "https://graph.facebook.com"
An access_token is now required. This can be an app or page access_token; no user authentication is required.
If you'd like to do this in PHP in a with-out waiting for a reply, the following function will do this:
//Provide a URL in $url to empty the OG cache function clear_open_graph_cache($url, $token) { $vars = array('id' => $url, 'scrape' => 'true', 'access_token' => $token); $body = http_build_query($vars); $fp = fsockopen('ssl://graph.facebook.com', 443); fwrite($fp, "POST / HTTP/1.1\r\n"); fwrite($fp, "Host: graph.facebook.com\r\n"); fwrite($fp, "Content-Type: application/x-www-form-urlencoded\r\n"); fwrite($fp, "Content-Length: ".strlen($body)."\r\n"); fwrite($fp, "Connection: close\r\n"); fwrite($fp, "\r\n"); fwrite($fp, $body); fclose($fp); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With