doujian3132 2011-12-15 08:21
浏览 96
已采纳

iTunes Podcast RSS PHP跟踪 - 不下载

I am trying to track downloads of MP3 Podcasts in iTunes. I have created a simple codeignitor site which generates URLS like:

www.site.com/podcasts/download/[id].mp3

The script takes the ID out of the URL, checks it exists in the DB - Gets the URL of the files and then does the following:

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 01 Jan 2011 01:01:01 GMT"); 
header('Content-type: audio/mpeg');
header('Content-Disposition: attachment; filename=episode'.$id.'.mp3"');
readfile($this->podcast_model->get_strPodcastFileName());   

If you hit the URL in a browser it works and the file starts to download, but when putting 1 link into iTunes it starts saying "Downloading 0%" but does not download?

The 1 thing to note is the method: $this->podcast_model->get_strPodcastFileName() returns a HTTP:// link and not a link to a file on the server, also the HTTP address is not on the same server as the script. Although this is working when downloading the files via the browser as I said above.

Does anyone have any ideas?

Thanks James

  • 写回答

1条回答 默认 最新

  • dongyijing2353 2011-12-15 21:07
    关注

    I fixed it by instead of using readfile(...) I simply did a header 301 redirect to the URL like this:

    header("HTTP/1.1 301 Moved Permanently" ); 
    header("Location: http://www.url_to_mp3_file/1.mp3");  
    

    One point for anyone else who is trying this. I would suggest you do a check on database for previous downloads in last X minutes (I check again IP address, URL and timestamp) as some MP3/Audio players make several requests to buffer the file.

    Hope this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我的数据无法存进链表里
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端