Exemplo n.º 1
0
 /**
  *
  * Execute the Request
  *
  * @return LoginResponse the Login Response
  * @throws CasperException
  * @throws \Exception
  */
 public function execute()
 {
     $this->clearHeaders();
     $this->clearParams();
     $login = $this->snapchat->getCasper()->getSnapchatIOSLogin($this->username, $this->password, $this->snapchat->getDeviceTokenIdentifier(), $this->snapchat->getDeviceTokenVerifier(), $this->pre_auth_token);
     $this->url = $login["url"];
     foreach ($login["headers"] as $key => $value) {
         $this->addHeader($key, $value);
     }
     foreach ($login["params"] as $key => $value) {
         $this->addParam($key, $value);
     }
     $response = parent::execute();
     if (!$response->isOK()) {
         throw new \Exception(sprintf("[%s] Login Failed!", $response->getCode()));
     }
     return $this->mapper->map($response->getData(), new LoginResponse());
 }
Exemplo n.º 2
0
 /**
  *
  * Execute the Request
  *
  * @return object Response Data
  * @throws CasperException
  * @throws \Exception
  */
 public function execute()
 {
     $endpointAuth = $this->snapchat->getCasper()->getSnapchatIOSEndpointAuth($this->getUsername(), $this->getAuthToken(), $this->getEndpoint());
     foreach ($endpointAuth["headers"] as $key => $value) {
         $this->addHeader($key, $value);
     }
     foreach ($endpointAuth["params"] as $key => $value) {
         $this->addParam($key, $value);
     }
     $this->casperAuthCallback($endpointAuth);
     $response = parent::execute();
     $this->response = $response;
     if ($this->interceptResponse($response)) {
         return null;
     }
     if (!$response->isOK()) {
         throw new \Exception(sprintf("[%s] [%s] Request Failed!", $this->getEndpoint(), $response->getCode()));
     }
     if ($this->parseResponse()) {
         return $this->mapper->map($response->getData(), $this->getResponseObject());
     }
     return $response->getData();
 }