showtimesByTheaters($code_cine); debug("Result :"); debug($result,true); } catch( ErrorException $error ) { die("Error retreiving informations (Err. n°". $error->getCode(). ") : ". $error->getMessage()); } try { debug("Parse result content..."); $name_cine=null; $movies=array(); foreach($result->theaterShowtimes as $t) { $name_cine=$t->place->theater->name; debug("Cine name : $name_cine"); foreach($t->movieShowtimes as $mst) { $movie=utf8_encode($mst->onShow->movie->title); $suf=array(); if ($mst->screenFormat['$']=='3D') { $suf[]='3D'; } if ($mst->version->code!=6001) { $suf[]='VO'; } if(count($suf)>0) { $movie.=' ('.implode('/',$suf).')'; } if (!isset($movies[$movie])) { debug("New movie : $movie"); $movies[$movie]=array(); } foreach($mst->scr as $day) { $date=DateTime::createFromFormat('Y-m-d',$day['d']); $jour=str_replace('.','',strftime('%a',$date->getTimestamp())); if(!isset($movies[$movie][$jour])) $movies[$movie][$jour]=array(); foreach($day['t'] as $t) { debug("New schedule time for movie $movie : day=$jour / time=".$t['$']); $movies[$movie][$jour][]=$t['$']; } } } } } catch( ErrorException $error ) { die("Error parsing informations (Err. n°".$error->getCode().") : ".$error->getMessage()); } debug("Parsing result :".print_r($movies,1)); // Format movies informations $fmovies=group_days($movies); debug("Formated movies informations : ".print_r($fmovies,1)); // Calculate start/end of cine week $start_date=new Datetime(date('Y-m-d').' 00:00:00'); $start=$start_date->format('d/m'); $start_time=$start_date->getTimestamp(); $start_wd=(int)date('N',$start_time); $end_time=$start_time+(24*3600*((9-$start_wd)%7)); $end=date('d/m',$end_time); // Format Message $msg="Cinema $name_cine\nProgramme du $start au $end\n"; foreach($fmovies as $m => $ps){ $msg.="$m : "; $hss=array(); foreach($ps as $p => $hs) { $hss[]="$p ".implode(' & ',$hs); } $msg.=implode(' / ',$hss)."\n"; } // Remove accents $msg=$msg=withoutAccents($msg); if ($send_to && $mail_domain) { // Format mail $mail="$send_to@$mail_domain"; // Display message echo "Send to $mail :\n\n$msg"; // Send message mail($mail,'',$msg); } else { echo "$msg"; }