<?php

preg_match("/^agrobr-app02\.*/", gethostname(), $matches);

require_once('Agro_Curl.php');

$now = new \Datetime;

try {
    echo "\n{$now->format('Y-m-d H:i:s')}: Atualizando arquivos de foto:\n";

    if (count($matches) > 0) {
        set_include_path(get_include_path().':/var/www/html/library/');
        $agro_curl = new Agro_Curl('agronet.agrobrasilseguros.com.br', 'https');
    } else {
        set_include_path(get_include_path().':/usr/share/php/:../library/');
        $agro_curl = new Agro_Curl('0.0.0.0:80', 'http');
    }

    $agro_curl->setUrl('/seguro/vistoriaprevia/atualizaflagtransmitidoseguradoraarquivosfoto');
    $agro_curl->doRequest('POST', array('idSafra' => 26));

    $response = $agro_curl->getResult();

    echo "\n{$now->format('Y-m-d H:i:s')}: {$response->message}\n";
} catch (\Exception $e) {
    echo "\n{$now->format('Y-m-d H:i:s')}: {$e->getMessage()}\n";
}