public function register_app() { $this->assertLoggedIn(); $this->setTitle("Register your App"); if ($this->args('submit')) { if (!$this->args('name')) { $errors['name'] = 'You must enter a name.'; $errorfields['name'] = 'error'; } if (!$this->args('app_url')) { $errors['app_url'] = 'You must enter an app URL.'; $errorfields['app_url'] = 'error'; } if (empty($errors)) { $app = new OAuthConsumer(); $app->set('name', $this->args('name')); $app->set('app_url', $this->args('app_url')); $app->set('user_id', User::$me->id); $app->set('consumer_key', MyOAuthProvider::generateToken()); $app->set('consumer_secret', MyOAuthProvider::generateToken()); $app->set('active', 1); $app->save(); Activity::log("registered a new app named " . $app->getLink() . "."); $this->forwardToUrl($app->getUrl()); } else { $this->set('errors', $errors); $this->set('errorfields', $errorfields); } } }
public function changeToAccessToken() { $this->set('token', MyOAuthProvider::generateToken()); $this->set('token_secret', MyOAuthProvider::generateToken()); $this->set('type', OAuthToken::$ACCESS); $this->set('verifier', ''); $this->save(); }
public static function create($name, $app_url) { $app = new OAuthConsumer(); $app->set('name', $name); $app->set('app_url', $app_url); $app->set('user_id', User::$me->id); $app->set('consumer_key', MyOAuthProvider::generateToken()); $app->set('consumer_secret', MyOAuthProvider::generateToken()); $app->set('active', 1); $app->save(); return $app; }
public function api_requesttoken() { //pull in our interface class. $provider = $this->get('provider'); //this is where we generate our token. $token_key = MyOAuthProvider::generateToken(); $token_secret = MyOAuthProvider::generateToken(); //okay, save it to the db. $t = new OAuthToken(); $t->set('type', 1); $t->set('consumer_id', $provider->consumer->id); $t->set('token', $token_key); $t->set('token_secret', $token_secret); $t->save(); $data['oauth_token'] = $token_key; $data['oauth_token_secret'] = $token_secret; return $data; }
public function api_requesttoken() { //pull in our interface class. $provider = $this->get('provider'); //this is where we generate our token. $token_key = MyOAuthProvider::generateToken(); $token_secret = MyOAuthProvider::generateToken(); //okay, save it to the db. $t = new OAuthToken(); $t->set('type', OauthToken::$REQUEST); $t->set('consumer_id', $provider->consumer->id); $t->set('token', $token_key); $t->set('token_secret', $token_secret); $t->set('ip_address', $_SERVER['REMOTE_ADDR']); $t->set('last_seen', date("Y-m-d H:i:s")); $t->save(); $data['oauth_token'] = $token_key; $data['oauth_token_secret'] = $token_secret; return $data; }