function fbconnect_test_fb_session in Facebook Connect 8.2
Same name and namespace in other branches
- 6.2 tests/fbconnect_test.module \fbconnect_test_fb_session()
- 7.2 tests/fbconnect_test.module \fbconnect_test_fb_session()
1 string reference to 'fbconnect_test_fb_session'
- fbconnect_test_menu in tests/
fbconnect_test.module - Implements hook_menu().
File
- tests/
fbconnect_test.module, line 16
Code
function fbconnect_test_fb_session($form, &$form_state) {
$form['fbuid'] = array(
'#type' => 'textfield',
'#title' => 'FB UID',
'#required' => TRUE,
);
$form['access_token'] = array(
'#type' => 'textfield',
'#title' => 'Access Token',
'#required' => TRUE,
'#maxlength' => 256,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
if (($client = facebook_client()) && !empty($_SESSION['fbconnect_token'])) {
try {
$fb_user = fbconnect_graph_query('/me', array(), 'GET');
if (!empty($fb_user)) {
$fb_user = $fb_user
->asArray();
$fbuid = $fb_user['id'];
}
else {
$fbuid = 0;
}
} catch (Exception $e) {
$fbuid = 0;
}
if ($fbuid) {
$form['fbuid']['#default_value'] = $fbuid;
$form['access_token']['#default_value'] = $client
->getApp()
->getAccessToken()
->getValue();
}
}
return $form;
}