View source
<?php
function fb_stream_requirements($phase) {
$t = get_t();
$items = array();
if ($phase == 'runtime') {
$token = variable_get(FB_STREAM_VAR_TOKEN, '');
if ($token) {
try {
$from = fb_graph('me', array(
'access_token' => $token,
));
$via = fb_graph('app', array(
'access_token' => $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;
}