From 6acda82bb3c881f9b44e6236912aefe8cc68543f Mon Sep 17 00:00:00 2001 From: marcus Date: Wed, 24 Sep 2008 14:27:18 +0000 Subject: Added create_api_user git-svn-id: https://code.elgg.org/elgg/trunk@2112 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/api.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'engine') 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 @@ -680,6 +680,26 @@ return false; } + /** + * 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. -- cgit v1.2.3