You are here

function _fb_social_comments_seo in Facebook social plugins integration 7.2

Same name and namespace in other branches
  1. 6.2 plugins/fb_plugin/comments.inc \_fb_social_comments_seo()

Get comments from facebook using graph api

2 calls to _fb_social_comments_seo()
fb_social_box_view in ./fb_social.module
returns the fbml content of the plugin
fb_social_preset_view in ./fb_social.module
returns the fbml content of the plugin

File

plugins/fb_plugin/comments.inc, line 273

Code

function _fb_social_comments_seo($url, $nr_comments, $cache_length) {
  $cache_key = md5('fb_social_comments_seo' . $url);
  $comments = "";
  if ($cache = cache_get($cache_key)) {
    $comments = $cache->data;
  }
  else {
    $req_url = "https://graph.facebook.com/comments/?ids=" . $url;
    if ($nr_comments) {
      $req_url .= "&limit={$nr_comments}";
    }
    $request = drupal_http_request($req_url);
    if ($request->code == 200) {
      $result = json_decode($request->data);
      $comments = _fb_social_comments_seo_view($result->{$url}->comments->data);
    }
    cache_set($cache_key, $comments, 'cache', REQUEST_TIME + 60 * $cache_length);
  }
  return $comments;
}