fix variable url

This commit is contained in:
2017-05-03 14:06:04 +12:00
parent 3b48e2e63f
commit f3be6e6c64

View File

@@ -7,6 +7,9 @@ class EventCinema extends PhpObject
private $asMovies;
//Remote
const PROM_LINKS = array( 'https://www.eventcinemas.co.nz/Promotions/MemberMovieOfTheWeek#cinemas=502',
'https://www.eventcinemas.co.nz/Promotions/MembersMovieOfTheWeek#cinemas=502');
const PROM_LINK = 'https://www.eventcinemas.co.nz/Promotions/MemberMovieOfTheWeek#cinemas=502';
public function __construct()
@@ -82,9 +85,16 @@ class EventCinema extends PhpObject
}
private function getMovieOfTheWeek()
{
$sTitle = '';
$sDates = '';
$sWorkingLink = '';
//Tests all URLs
foreach(self::PROM_LINKS as $sLink)
{
//Get Event Cinema Page
$sContent = $this->getCurl(self::PROM_LINK);
$sContent = $this->getCurl($sLink);
//Build DOM
$oDom = new DOMDocument();
@@ -92,12 +102,18 @@ class EventCinema extends PhpObject
$oXPath = new DOMXPath($oDom);
//Get header object
$oHeader = $oXPath->query('//*[@class="header-title"]//*[@class="featured-name arrow-top small"]')->item(0)->childNodes;
$oMovieSection = $oXPath->query('//*[@class="header-title"]//*[@class="featured-name arrow-top small"]');
if($oMovieSection->length > 0)
{
$oHeader = $oMovieSection->item(0)->childNodes;
$sTitle = $oHeader->item(3)->nodeValue;
$aoDetails = $oHeader->item(5)->childNodes;
$sDates = mb_substr($aoDetails->item(1)->nodeValue, 6);
return array('title'=>$sTitle, 'dates'=>$sDates);
$sWorkingLink = $sLink;
break;
}
}
return array('title'=>$sTitle, 'dates'=>$sDates, 'link'=>$sWorkingLink);
}
public function getRss()
@@ -117,7 +133,7 @@ class EventCinema extends PhpObject
{
$asItem = array();
$asItem['title'] = $asMovie['title'];
$asItem['link'] = self::PROM_LINK;
$asItem['link'] = $asMovie['link'];
$asItem['guid'] = $asMovie['title'];
$asItem['category'] = 'Movies';
$asItem['pub_date'] = date('r');