Пример #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $app = $this->getProjectApplication();
     $this->logger = $this->getLogger();
     $this->regionService = $app['region.skyforge.service'];
     $this->regionService->setRegion($input->getOption('region'));
     $authData = $this->regionService->getAuthOptions();
     $client = Client::getInstance();
     //        $client->getEngine()->debug(true);
     $client->getEngine()->addOption('--config=' . $app['config']['app']['path'] . '/phantomjs.json');
     $client->getEngine()->setPath($app['config']['app']['path'] . '/../bin/phantomjs');
     //        $request = $client->getMessageFactory()->createCaptureRequest($authData['url'], $authData['method']);
     //        $request->setRequestData($authData['data']);
     $request = $client->getMessageFactory()->createCaptureRequest('http://erliz.ru/', 'GET');
     $response = $client->getMessageFactory()->createResponse();
     $request->setDelay(5);
     $request->setViewportSize(1920, 1080);
     $request->setOutputFile($app['config']['app']['path'] . '/log/screen_test_' . time() . '.jpg');
     $client->send($request, $response);
     if ($response->getStatus() === 200) {
         print_r($response->getContent());
     }
     //        print_r($client->getLog());
 }
Пример #2
0
 private function authorize()
 {
     if ($this->regionService->getRegion() != RegionService::RU_REGION) {
         throw new RuntimeException('Need authorize', 403);
     }
     $this->createClient(true, true);
     $authOptions = $this->regionService->getAuthOptions();
     /** @var ResponseInterface $response */
     if ($authOptions['method'] == 'GET') {
         $response = $this->client->get($authOptions['url']);
     } elseif ($authOptions['method'] == 'POST') {
         $response = $this->client->post($authOptions['url'], array('body' => $authOptions['data']));
     }
     $this->client->get($this->regionService->getProjectUrl() . 'skyforgenews');
     $this->exportCookie();
     //        foreach ($this->history->getRequests() as $request) {
     //            echo $request->getUrl() ."\n";
     //        }
     echo "authorize!\n";
     $this->tryAuthorize = true;
 }