Created
October 12, 2012 02:34
-
-
Save raytiley/3877011 to your computer and use it in GitHub Desktop.
Show search with schedule display - GROSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ss = isset($_GET['ss']) ? $_GET['ss'] : "peace"; //use a default search term for testing | |
$client = new SoapClient("http://tctvsbs.tctv.net/CablecastWS/CablecastWS.asmx?wsdl", array('cache_wsdl' => 0)); | |
$channels = array( | |
array("name" => "Channel 3", "id" => 1), | |
array("name" => "Channel 22", "id" => 4), | |
array("name" => "Channel 26", "id" => 5), | |
array("name" => "Channel 77", "id" => 6) | |
); | |
//We only need to do the search once as long as all channels are at the same location. | |
//We can use any channel we want. | |
$showsResult = $client->SimpleShowSearch(array( | |
'ChannelID' => 1, | |
'searchString' => $ss)); | |
//Make sure the results are an array | |
$shows = is_array($showsResult->SimpleShowSearchResult->SiteSearchResult->Shows->ShowInfo) ? | |
$showsResult->SimpleShowSearchResult->SiteSearchResult->Shows->ShowInfo : | |
array($showsResult->SimpleShowSearchResult->SiteSearchResult->Shows->ShowInfo); | |
//Itterate through all the shows and grab the schedule for each channel | |
foreach($shows as $show) { | |
echo "<h3>" . $show->Title . "ShowID (" . $show->ShowID . ")</h3>"; | |
$producer = $show->Producer; | |
if($producer!=""){ | |
echo "<h3 style='margin-bottom: 3px;'>Producer:</h3>$producer<br /><br />"; | |
} | |
$category = $show->Category; | |
if($category!=""){ | |
echo "<h3 style='margin-bottom: 3px;'>Category:</h3>$category<br /><br />"; | |
} | |
// Grab the showID from the show. | |
$showID = $show->ShowID; | |
date_default_timezone_set('America/Los_Angeles'); | |
$time = time(); | |
foreach($channels as $channel) { | |
$params = array( | |
'ChannelID' => $channel["id"], | |
'FromDate' => date("Y-m-d")."T00:00:00", | |
'ToDate' => date("2050-01-01")."T00:00:00", | |
'restrictToShowID' => $showID); | |
$schedule = $client->GetScheduleInformation($params); | |
echo "<h3 style='margin-bottom: 3px;'>".$channel["name"]." Air Dates:</h3>"; | |
if(!isset($schedule->GetScheduleInformationResult->ScheduleInfo)) { | |
echo "Not currently scheduled"; | |
continue; | |
} | |
//Cast results to an array if not already | |
$runs = is_array($schedule->GetScheduleInformationResult->ScheduleInfo) ? | |
$schedule->GetScheduleInformationResult->ScheduleInfo : | |
array($schedule->GetScheduleInformationResult->ScheduleInfo); | |
$dateFormat = "l, F j, g:i a"; | |
foreach($runs as $run) | |
{ | |
$air_dates .= date($dateFormat,strtotime($run->StartTime)) . "<br />"; | |
} | |
if(!strstr($air_dates,"Wednesday, December 31, 4:00 pm")){ | |
echo $air_dates."<br />"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example is lacking a lot of error checking... strictly an example of how to use the api.