Пример #1
0
function api_keys_create(&$user)
{
    $id = dbtickets_create(64);
    $key = api_keys_generate_key();
    $secret = random_string(64);
    $now = time();
    $key_row = array('id' => $id, 'user_id' => $user['id'], 'app_key' => $key, 'app_secret' => $secret, 'created' => $now);
    # TO DO: callbacks and other stuff (what?)
    $insert = array();
    foreach ($key_row as $k => $v) {
        $insert[$k] = AddSlashes($v);
    }
    $rsp = db_insert('ApiKeys', $insert);
    if ($rsp['ok']) {
        $rsp['key'] = $key_row;
    }
    return $rsp;
}
Пример #2
0
function api_keys_create($user_id, $title, $description, $callback = '')
{
    $user = users_get_by_id($user_id);
    $id = dbtickets_create(64);
    $role_map = api_keys_roles_map('string keys');
    $role_id = $role_map['general'];
    $key = api_keys_generate_key();
    $secret = random_string(64);
    $now = time();
    $key_row = array('id' => $id, 'user_id' => $user['id'], 'api_key' => $key, 'app_secret' => $secret, 'created' => $now, 'last_modified' => $now, 'app_title' => $title, 'app_description' => $description, 'app_callback' => $callback);
    # TO DO: callbacks and other stuff (what?)
    $insert = array();
    foreach ($key_row as $k => $v) {
        $insert[$k] = AddSlashes($v);
    }
    $rsp = db_insert('ApiKeys', $insert);
    if ($rsp['ok']) {
        $rsp['key'] = $key_row;
    }
    return $rsp;
}