Last active
April 12, 2018 22:39
-
-
Save abediali/ee76a2fa36c2fbe3c1366a99504eed7e to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Synchronize to Hulu | |
*/ | |
protected function sendDatesToHulu($inField = "huluDatesNew", $outField = "huluResults") | |
{ | |
$debugFlag = isset($_REQUEST['syncDebug']) && $_REQUEST['syncDebug'] == "on"; | |
if ($debugFlag) | |
exit; | |
/* What services? */ | |
$services = array(); | |
if (isset($_REQUEST['sync_haap']) && $_REQUEST['sync_haap'] == "on") | |
$services[] = "haap_fvod"; | |
if (isset($_REQUEST['sync_fvod']) && $_REQUEST['sync_fvod'] == "on") | |
$services[] = "fvod"; | |
/* Loop */ | |
foreach($this->$inField as $huluId => $huluDate) { | |
foreach($services as $service) { | |
//echo $huluId . ": " . $huluDate . "<br/>\n"; | |
$url = "https://content.hulu.com/api/v1/asset/$huluId/dates/$service?guid=e7b79f24-41c5-48e0-9d00-23a15a011b6b"; | |
$data_string = $huluDate; //"{\"start_date\": \"$startDate\", \"end_date\": \"$endDate\"}"; | |
// yyy | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Content-Type: application/json', | |
'Content-Length: ' . strlen($data_string)) | |
); | |
$result = curl_exec($ch); | |
//$huluResults[$huluId] = $result; | |
if (isset($huluResults[$huluId])) | |
$huluResults[$huluId] .= "\n" . $result; | |
else | |
$huluResults[$huluId] = $result; | |
} | |
} | |
$this->$outField = $huluResults; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment