function fb_token_save in Drupal for Facebook 7.4
Save a token to the fb_token table.
3 calls to fb_token_save()
File
- ./
fb.module, line 843
Code
function fb_token_save($token, $params = array()) {
// Defaults.
$params = $params + array(
'status' => FB_STATUS_FLAG_VALID,
'access_token' => $token,
'changed' => REQUEST_TIME,
'data' => NULL,
);
if (empty($params['fbu']) || empty($params['fba'])) {
if (empty($params['graph'])) {
$params['graph'] = fb_graph_batch(array(
'me',
'app',
), $params['access_token'], FB_CACHE_STORE);
}
$params['fbu'] = $params['graph']['me']['id'];
$params['fba'] = $params['graph']['app']['id'];
}
$result = db_merge('fb_token')
->key(array(
'fba' => $params['fba'],
'fbu' => $params['fbu'],
))
->fields(array(
'access_token' => $params['access_token'],
'status' => $params['status'],
'changed' => $params['changed'],
'data' => $params['data'] ? serialize($params['data']) : NULL,
))
->execute();
if ($result) {
return $params;
}
}