我需要通过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
答案 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);