Flush facebook open graph node cache in drupal 7

Hi Sometimes facebook cache doesn't allow us to make visible changes we made into node. To prevent this cache issues we can create custom module and add hook given below. It will flush facebook cache on node update event.

Thank you. Continue doing drupal!

 

/**
 * Implements hook_node_presave().
 */
function yourmodulename_node_presave($node) {
  // Works only on node update.
  if (!empty($node->nid)) {
    global $base_url;
    $url = $base_url;
    // For debug.
    //$url = str_replace('local', 'www', $base_url);

    $data = 'id=' . $url . url('node/'. $node->nid) . '&scrape=TRUE';
    $options = array(
      'method' => 'POST',
      'data' => $data,
    );
    $result = drupal_http_request('https://graph.facebook.com', $options);
  }
}