Пример #1
0
 protected function getLoginFromUser()
 {
     $dialog = $this->getHelperSet()->get('dialog');
     if ($dialog->askConfirmation($this->output, $dialog->getQuestion('Would you like login with your credentials', 'yes', '?'), true)) {
         $this->client->setApiKey(null);
         $this->client->setApiSecret(null);
         $email = $dialog->askAndValidate($this->output, "Enter your Control Panel Email: ", function ($value) {
             if (null === $value) {
                 throw new \Exception("Please enter a valid email address");
             }
             return $value;
         });
         $passwd = $dialog->askAndValidate($this->output, "Enter your Control Panel Password: "******"Please enter your password");
             }
             return $value;
         });
         $this->output->write("<info>Authenticating...</info>");
         $res = $this->call('authentication/getLoggedUser', array('apiUsername' => $email, 'apiPassword' => $passwd));
         if (!$res) {
             $this->output->writeln("Authentication failed. Please check your credentials and try again.");
             die(1);
         }
         $this->output->writeln(" <info>OK!</info>");
         $this->client->setArg('apiUsername', $email);
         $this->client->setArg('apiPassword', $passwd);
     }
 }
Пример #2
0
 /**
  * @return APIClient
  */
 public function getClient()
 {
     if (null === $this->client) {
         $this->client = new APIClient(self::URL);
         $this->client->setApiKey(isset($_SERVER['SG_API_KEY']) ? $_SERVER['SG_API_KEY'] : self::DEMO_API_KEY);
         $this->client->setApiSecret(isset($_SERVER['SG_API_SECRET']) ? $_SERVER['SG_API_SECRET'] : self::DEMO_API_SECRET);
     }
     return $this->client;
 }