Esempio n. 1
0
 /**
  * @inheritdoc
  */
 public function api($apiSubUrl, $method = 'GET', array $params = [], array $headers = [], $delay = false)
 {
     $this->sleep($delay);
     $response = parent::api($apiSubUrl, $method, $params, $headers);
     if (ArrayHelper::getValue($response, 'error.error_code') == 14 && $this->captcha) {
         if ($this->captcha->run(ArrayHelper::getValue($response, 'error.captcha_img'))) {
             $response = $this->api($apiSubUrl, $method, ArrayHelper::merge($params, ['captcha_sid' => ArrayHelper::getValue($response, 'error.captcha_sid'), 'captcha_key' => $this->captcha->result()]), $headers);
         } else {
             throw new Exception($this->captcha->error());
         }
     } elseif (ArrayHelper::getValue($response, 'error')) {
         throw new Exception(ArrayHelper::getValue($response, 'error.error_msg'), ArrayHelper::getValue($response, 'error.error_code'));
     }
     return $response;
 }
Esempio n. 2
0
 /**
  * @param int $limit
  *
  * @return array
  * @throws Exception
  */
 public function getPosts($limit = 100)
 {
     return $this->parseGetPosts($this->service->api($this->getWallGetRequestUrl($limit), 'GET'), 'response', ['id', 'text'], ['service_id_author' => 'from_id', 'service_id_post' => 'id', 'time_created' => 'date', 'content' => 'text']);
 }