예제 #1
0
파일: app.php 프로젝트: ricberw/BotQueue
 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);
         }
     }
 }
예제 #2
0
 public function changeToAccessToken()
 {
     $this->set('token', MyOAuthProvider::generateToken());
     $this->set('token_secret', MyOAuthProvider::generateToken());
     $this->set('type', OAuthToken::$ACCESS);
     $this->set('verifier', '');
     $this->save();
 }
예제 #3
0
 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;
 }
예제 #4
0
파일: apiv1.php 프로젝트: ricberw/BotQueue
 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;
 }
예제 #5
0
파일: apiv1.php 프로젝트: eric116/BotQueue
 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;
 }