예제 #1
0
 public function __construct($consumerKey = NULL, $consumerSecret = NULL, $serializer = NULL, $applicationName = NULL, $use_compression = FALSE, $username = NULL, $password = NULL, $session_file = '/tmp/session.dat')
 {
     $this->use_compression = $use_compression;
     if (empty($applicationName)) {
         $this->applicationName = $this->wrapperName . '/' . WRAPPER_VERSION;
     } else {
         $this->applicationName = $applicationName . '/' . $this->wrapperName . '/' . WRAPPER_VERSION;
     }
     if (empty($serializer)) {
         $serializer = new JsonSerializer();
     }
     $this->serializer = $serializer;
     $this->format = $serializer->getType();
     $this->applicationName = $this->applicationName . '/' . strtoupper($this->format);
     if (empty($consumerKey) && empty($consumerSecret)) {
         list($consumerKey, $consumerSecret) = $this->obtainKeys($username, $password, $session_file);
         if (empty($consumerKey) || empty($consumerSecret)) {
             throw new \Exception('Cannot obtain Semantria keys. Wrong username or password.');
         }
     }
     if (empty($consumerKey)) {
         throw new \Exception('Consumer KEY can\'t be empty.');
     }
     if (empty($consumerSecret)) {
         throw new \Exception('Consumer SECRET can\'t be empty.');
     }
     $this->consumerKey = $consumerKey;
     $this->consumerSecret = $consumerSecret;
     $this->request = new AuthRequest($this->consumerKey, $this->consumerSecret, $this->applicationName, $this->use_compression);
 }
 public function __construct($consumerKey, $consumerSecret, $serializer = NULL, $applicationName = NULL, $use_compression = FALSE)
 {
     if (empty($consumerKey)) {
         throw new \Exception('Consumer KEY can\'t be empty.');
     }
     if (empty($consumerSecret)) {
         throw new \Exception('Consumer SECRET can\'t be empty.');
     }
     $this->consumerKey = $consumerKey;
     $this->consumerSecret = $consumerSecret;
     $this->use_compression = $use_compression;
     if (empty($applicationName)) {
         $this->applicationName = $this->wrapperName . '/' . WRAPPER_VERSION;
     } else {
         $this->applicationName = $applicationName . '/' . $this->wrapperName . '/' . WRAPPER_VERSION;
     }
     if (empty($serializer)) {
         $serializer = new JsonSerializer();
     }
     $this->serializer = $serializer;
     $this->format = $serializer->getType();
     $this->applicationName = $this->applicationName . '/' . strtoupper($this->format);
     $this->request = new AuthRequest($this->consumerKey, $this->consumerSecret, $this->applicationName, $this->use_compression);
 }