2015-05-13 22:05:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Common_TuneIn
|
|
|
|
{
|
|
|
|
public static function sendMetadataToTunein($title, $artist)
|
|
|
|
{
|
2015-05-19 21:42:07 +02:00
|
|
|
$credQryStr = self::getCredentialsQueryString();
|
|
|
|
$metadataQryStr = "&title=".$title."&artist=".$artist."&commercial=false";
|
|
|
|
|
|
|
|
$ch = curl_init();
|
|
|
|
curl_setopt($ch, CURLOPT_URL, TUNEIN_API_URL . $credQryStr . $metadataQryStr);
|
|
|
|
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
|
|
|
|
|
|
|
curl_exec($ch);
|
|
|
|
if (curl_error($ch)) {
|
|
|
|
Logging::error("Failed to reach TuneIn: ". curl_errno($ch)." - ". curl_error($ch) . " - " . curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
|
|
|
|
}
|
|
|
|
curl_close($ch);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private static function getCredentialsQueryString() {
|
2015-05-19 20:39:05 +02:00
|
|
|
$tuneInStationID = Application_Model_Preference::getTuneinStationId();
|
|
|
|
$tuneInPartnerID = Application_Model_Preference::getTuneinPartnerId();
|
|
|
|
$tuneInPartnerKey = Application_Model_Preference::getTuneinPartnerKey();
|
2015-05-13 22:05:37 +02:00
|
|
|
|
2015-05-19 21:42:07 +02:00
|
|
|
return "?partnerId=".$tuneInPartnerID."&partnerKey=".$tuneInPartnerKey."&id=".$tuneInStationID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function updateOfflineMetadata() {
|
|
|
|
$credQryStr = self::getCredentialsQueryString();
|
2015-05-13 22:05:37 +02:00
|
|
|
|
|
|
|
$ch = curl_init();
|
2015-05-19 21:42:07 +02:00
|
|
|
curl_setopt($ch, CURLOPT_URL, TUNEIN_API_URL . $credQryStr . "&commercial=true");
|
2015-05-13 22:05:37 +02:00
|
|
|
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
|
|
|
|
2015-05-19 20:39:05 +02:00
|
|
|
curl_exec($ch);
|
2015-05-13 22:05:37 +02:00
|
|
|
if (curl_error($ch)) {
|
|
|
|
Logging::error("Failed to reach TuneIn: ". curl_errno($ch)." - ". curl_error($ch) . " - " . curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
|
|
|
|
}
|
|
|
|
curl_close($ch);
|
|
|
|
}
|
2015-05-19 20:39:05 +02:00
|
|
|
|
2015-05-13 22:05:37 +02:00
|
|
|
}
|