You are here

fb_stream.install in Drupal for Facebook 7.3

Same filename and directory in other branches
  1. 6.3 fb_stream.install

File

fb_stream.install
View source
<?php

/**
 * Implementation of hook_requirements().
 */
function fb_stream_requirements($phase) {
  $t = get_t();
  $items = array();
  if ($phase == 'runtime') {
    $token = variable_get(FB_STREAM_VAR_TOKEN, '');
    if ($token) {
      try {

        // TODO: consolodate graph api, use batch.
        $from = fb_graph('me', array(
          'access_token' => $token,
        ));
        $via = fb_graph('app', array(
          'access_token' => $token,
        ));

        // Show helpful messages about the current access token.
        $items[] = array(
          'title' => t('Facebook stream posts'),
          'value' => t('OK'),
          'severity' => REQUIREMENT_OK,
          'description' => t('Posting to facebook as !user, via the !app application.', array(
            '!user' => l(_fb_get_name($from), $from['link']),
            '!app' => l(_fb_get_name($via), $via['link']),
          )),
        );
      } catch (Exception $e) {
        $items[] = array(
          'title' => t('Facebook stream posts'),
          'value' => t('Could not confirm token'),
          'severity' => REQUIREMENT_ERROR,
          'description' => t('Posting to facebook will not succeed.  The <a href=!url>access token</a> may have expired.  %message', array(
            '%message' => $e
              ->getMessage(),
            '!url' => url(FB_PATH_ADMIN . '/fb_stream'),
          )),
        );
      }
    }
    else {
      $items[] = array(
        'title' => t('Facebook stream posts'),
        'value' => t('No token'),
        'severity' => REQUIREMENT_WARNING,
        'description' => t('Posting to facebook will not succeed without an <a href=!url>access token</a>.', array(
          '!url' => url(FB_PATH_ADMIN . '/fb_stream'),
        )),
      );
    }
  }
  return $items;
}

Functions

Namesort descending Description
fb_stream_requirements Implementation of hook_requirements().