選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

C903IP.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: robin
  5. * Date: 8/21/16
  6. * Time: 3:25 PM
  7. */
  8. namespace App\Http\Business\Cameras\Elro;
  9. use App\Http\Business\Cameras\AbstractCamera;
  10. use App\Http\DBO\CamerasDbo;
  11. use GuzzleHttp\Client;
  12. use Luticate\Utils\LuLog;
  13. class C903IP extends AbstractCamera
  14. {
  15. const URI = "/snapshot.cgi";
  16. private $_client;
  17. private $_url;
  18. public function __construct(CamerasDbo $camera)
  19. {
  20. parent::__construct($camera);
  21. $this->_client = new Client();
  22. $data = $camera->getData();
  23. $this->_url = "http://" . $data["Host"] . ":" . $data["Port"] . self::URI;
  24. }
  25. public function prepareImage()
  26. {
  27. $username = $this->_camera->getData()["Username"];
  28. $passwd = $this->_camera->getData()["Password"];
  29. try {
  30. $response = $this->_client->request('GET', $this->_url, ['auth' => [
  31. $username,
  32. $passwd
  33. ]]);
  34. $data = (string)$response->getBody();
  35. $this->_image = $this->_imagine->load($data);
  36. } catch (\Exception $e) {
  37. LuLog::log($e);
  38. }
  39. }
  40. }