簡體   English   中英

php 更新 Icecast 元數據

[英]Icecast metadata update by php

我需要通過 PHP 讓 Icecast 元數據自動更新讓說每 15 分鍾,這將由 cPanel cronjob 完成。

我有下面的代碼,但它不起作用(如果我使用標頭位置重定向它會起作用,但是 cronjob 將無法做到這一點)

<?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
curl_exec($ch);

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

?>

使用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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM