This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
api:ukazky [2017/07/19 15:19] – [stažení nahrávek hovorů] root | api:ukazky [2019/01/23 09:55] – [stažení nahrávek hovorů] root | ||
---|---|---|---|
Line 133: | Line 133: | ||
=== PHP === | === PHP === | ||
- | Script below downloads all available recordings (stored at Odorik.cz) recordings from yeasterday. | ||
- | <code php> | ||
- | <?php | ||
- | $auth = array(' | ||
- | ' | ||
- | |||
- | function calls_timespan_params() { | ||
- | date_default_timezone_set(' | ||
- | |||
- | $now = date_create(' | ||
- | $yesterday = date_modify($now, | ||
- | |||
- | $from = date_create(date_format($yesterday, | ||
- | $to = date_create(date_format($yesterday, | ||
- | |||
- | return array( ' | ||
- | ' | ||
- | } | ||
- | |||
- | function download($url) { | ||
- | $curl = curl_init(); | ||
- | curl_setopt($curl, | ||
- | curl_setopt($curl, | ||
- | $data = curl_exec($curl); | ||
- | curl_close($curl); | ||
- | |||
- | return $data; | ||
- | } | ||
- | |||
- | function download_recording($call, | ||
- | $fname = filename($call); | ||
- | |||
- | if (file_exists($fname)) { | ||
- | fwrite(STDERR, | ||
- | return(-1); | ||
- | } | ||
- | |||
- | $auth_qs = http_build_query($auth); | ||
- | $data = download(' | ||
- | |||
- | $file = fopen($fname, | ||
- | fputs($file, | ||
- | fclose($file); | ||
- | } | ||
- | |||
- | function filename($call) { | ||
- | # | ||
- | #exit(0); | ||
- | |||
- | #return $call-> | ||
- | return $call-> | ||
- | } | ||
- | |||
- | $qs = http_build_query(array_merge($auth, | ||
- | $calls = json_decode(download(" | ||
- | |||
- | foreach($calls as $call) { | ||
- | if ($call-> | ||
- | download_recording($call, | ||
- | } | ||
- | } | ||
- | ?> | ||
- | </ | ||