diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-09-24 14:27:18 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-09-24 14:27:18 +0000 |
commit | 6acda82bb3c881f9b44e6236912aefe8cc68543f (patch) | |
tree | 3b72ea9d797123d970a9b33d08ad648aedc97457 /engine/lib/api.php | |
parent | 40108e73df02d828d85cf4c90202277e400f550b (diff) | |
download | elgg-6acda82bb3c881f9b44e6236912aefe8cc68543f.tar.gz elgg-6acda82bb3c881f9b44e6236912aefe8cc68543f.tar.bz2 |
Added create_api_user
git-svn-id: https://code.elgg.org/elgg/trunk@2112 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/api.php')
-rw-r--r-- | engine/lib/api.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/engine/lib/api.php b/engine/lib/api.php index ac4e5edbd..04a1a971f 100644 --- a/engine/lib/api.php +++ b/engine/lib/api.php @@ -681,6 +681,26 @@ } /** + * Generate a new API user for a site, returning a new keypair on success. + * + * @param int $site_guid The GUID of the site. + */ + function create_api_user($site_guid) + { + global $CONFIG; + + $site_guid = (int)$site_guid; + + $public = sha1(rand().$site_guid.microtime()); + $secret = sha1(rand().$site_guid.microtime().$public); + + if (insert_data("INSERT into {$CONFIG->dbprefix}api_users (site_guid, api_key, secret) values ($site_guid, '$public', '$private')")) + return get_api_user($site_guid, $public); + + return false; + } + + /** * This function looks at the super-global variable $_SERVER and extracts the various * header variables needed to pass to the validation functions after performing basic validation. * |