You are here

function _facebook_wall_error_msg in Facebook Wall 7

Generate error message and fetchs FB content.

Parameters

string $api_url: FB graph api url with access token and fields.

Return value

array Array of FB content on success data fetch and FALSE if it isn't.

5 calls to _facebook_wall_error_msg()
_facebook_wall_access_token_permission_info_array in ./facebook_wall.admin.inc
List permissions on access token of user.
_facebook_wall_page_info_array in ./facebook_wall.module
Generate basic FB page or user information content.
_facebook_wall_page_likes in ./facebook_wall.module
Admin configure form for Facebook Page Likes.
_facebook_wall_profile_picture in ./facebook_wall.module
Get FB user profile picture with given FB user id.
_facebook_wall_theme_html_content in ./facebook_wall.module
Generate HTML content from template file.

File

./facebook_wall.module, line 252
Get the current facebook wall posts of the given user or page.

Code

function _facebook_wall_error_msg($api_url = FALSE) {

  // Checks for FB access token exists.
  $message_display = variable_get('facebook_wall_message_show', 1);
  if (facebook_wall_access_token() == '') {
    $message = t('Please login to your facebook account and generate a valid access token. Click here to get') . ' ' . l(t('valid Access Token.'), 'admin/config/content/facebook_wall/settings');
    watchdog('facebook wall', $message, array(), WATCHDOG_DEBUG);
    if ($message_display) {
      drupal_set_message($message, 'warning');
    }
  }
  elseif (variable_get('facebook_wall_page_url', 'me') == '') {
    $message = t('Please enter your Facebook page username or ID. Click here to get') . ' ' . l(t('Facebook Page URL.'), 'admin/config/content/facebook_wall/settings');
    watchdog('facebook wall', $message, array(), WATCHDOG_DEBUG);
    if ($message_display) {
      drupal_set_message($message, 'warning');
    }
  }
  elseif ($api_url != FALSE) {

    // Fetching content from FB via CURL request.
    $fb_content = _facebook_wall_graph_api_content($api_url);
    if (!isset($fb_content)) {
      $message = t('Not able to connect with Facebook');
      watchdog('facebook wall', $message, array(), WATCHDOG_DEBUG);
      if ($message_display) {
        drupal_set_message($message, 'warning');
      }
    }
    elseif (isset($fb_content->error)) {
      $message = $fb_content->error->type . ' : ' . $fb_content->error->code . ' ! ' . $fb_content->error->message;
      watchdog('facebook wall', $message, array(), WATCHDOG_DEBUG);
      if ($message_display) {
        drupal_set_message($message, 'warning');
      }
    }
    else {

      // Arrary return from FB on success.
      return $fb_content;
    }
  }
  return FALSE;
}