2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2010 */
\r
6 /* Inclusive Design Institute */
\r
8 /* This program is free software. You can redistribute it and/or */
\r
9 /* modify it under the terms of the GNU General Public License */
\r
10 /* as published by the Free Software Foundation. */
\r
11 /************************************************************************/
\r
13 define('TR_INCLUDE_PATH', '../include/');
\r
14 require_once(TR_INCLUDE_PATH.'vitals.inc.php');
\r
15 require_once(TR_INCLUDE_PATH.'classes/Utility.class.php');
\r
16 require_once(TR_INCLUDE_PATH.'classes/DAO/OAuthServerConsumersDAO.class.php');
\r
18 if (!isset($_GET['consumer']))
\r
20 echo "error=".urlencode('Empty parameter: consumer');
\r
25 $consumer = $_GET['consumer'];
\r
26 $expire_threshold = intval($_GET['expire']);
\r
28 $oAuthServerConsumersDAO = new OAuthServerConsumersDAO();
\r
30 $consumer_info = $oAuthServerConsumersDAO->getByConsumer($consumer);
\r
32 if (!is_array($consumer_info))
\r
33 { // new consumer. save consumer and generate consumer key and secret
\r
34 $consumer_id = $oAuthServerConsumersDAO->Create($consumer, $expire_threshold);
\r
35 $consumer_info = $oAuthServerConsumersDAO->get($consumer_id);
\r
38 { // existing consumer
\r
39 if ($expire_threshold <> $consumer_info[0]['expire_threshold'])
\r
41 $oAuthServerConsumersDAO->updateExpireThreshold($consumer, $expire_threshold);
\r
42 $consumer_info[0]['expire_threshold'] = $expire_threshold;
\r
44 $consumer_info = $consumer_info[0];
\r
47 $consumer_key = $consumer_info['consumer_key'];
\r
48 $consumer_secret = $consumer_info['consumer_secret'];
\r
50 echo 'consumer_key='.$consumer_key.'&consumer_secret='.$consumer_secret.'&expire='.$expire_threshold;
\r