通过php更新Icecast元数据

时间:2018-02-20 13:41:18

标签: php cron cpanel icecast

我需要通过PHP获取Icecast元数据自动更新,每隔15分钟由cPanel cronjob完成。

我有以下代码,但它确实无效(如果我使用标题位置重定向,但cronjob无法做到这一点,则可行)

def list_packs(params) do
  pi_query = from pi in PackItem,
    join: i in assoc(pi, :item),
    where: i.active == true
  packs = Pack
    |> Repo.all()
    |> Repo.preload([:classroom, [packlanguages: :language, packitems: pi_query]])
end

1 个答案:

答案 0 :(得分:1)

使用curl_error执行呼叫后尝试检查错误:

<?php
$url="http://tgftp.nws.noaa.gov/data/observations/metar/stations/KJFK.TXT";
$info=file_get_contents($url);
$url_info = "http://username:password@icecast:8000/admin/metadata?mount=/mymount&mode=updinfo&song=" . urlencode($info);

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url_info);
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser, check for errors
if (curl_exec($ch) === FALSE)
{
  print 'Curl-Error occurred: ' . curl_error($ch).', error code: '.curl_errno($ch);
}

// close cURL resource, and free up system resources
curl_close($ch);