Ejemplo n.º 1
0
 /**
  * Capture Screenshot for a given URL
  * @param  ApiRequest      $request  Validates ApiKey "on the fly"
  * @param  PhantomJsClient $browser  Browser used to capture Screenshot
  * @param  ApiResponse     $response Do Response Stuff
  * @return json
  */
 public function captureScreenshot(ApiRequest $request, PhantomJsClient $browser, ApiResponse $response)
 {
     $browser->boot();
     $browser->setHeight($request->get('height', null));
     $browser->setWidth($request->get('width', null));
     $screenshot = $browser->capture($request->get('url'), $request->get('key'));
     $response->setRateLimitHeader($screenshot);
     return response()->json($response->getResponseArray($screenshot), 201, $response->getHeaders());
 }
Ejemplo n.º 2
0
 /**
  * Create screenshot through webinterface
  * @param  Request                                $request
  * @param  PhantomJsClient $browser
  * @return redirect
  */
 public function createTestScreenshot(Request $request, PhantomJsClient $browser)
 {
     $proof = trim(strtolower($request->get('proof')));
     if ($proof != 'laravel') {
         return back()->withMessage("Wrong answer. Hint: Laravel.");
     }
     try {
         $browser->boot();
         $screenshot = $browser->capture($request->get('url'), null);
         return redirect()->route('try')->withAsset($screenshot->getResponsePath());
     } catch (Exception $e) {
         // If something happens, send error to Sentry
         Log::error($e);
         return redirect()->route('try')->withError("Oh snap! Something went wrong, please try again.")->withInput();
     }
 }