dongpanbo4727 2012-07-28 06:55
浏览 35
已采纳

以特定间隔从XML Feed更新页面

I really hate to ask these vague questions, but I could use some help figuring out the best method to go about this idea.

What I'm doing is fairly simple. I'm creating a page that will display data from several sportsbooks as accurately as possible. There are several different sites, all with their own APIs, but the data is the pretty much the same. Some of them have restrictions on the number of times they can be accessed per day so I'm trying to figure out how to go about that.

Because of the whole cross domain issue with JavaScript, I was looking into setting something up with PHP to retrieve the data locally. Would it be possible for a script to access each API say 4 times a day at certain times, parse the data locally and then serve it up with AJAX or something else?

Would it make sense to store the data in a MYSQL database and then query it? What I'm looking to do seems as simple as displaying live XML data, I just need to figure out a way not to exceed the API calls for the day. I'm fairly new to server side code in general so I apologize if this is blatantly obvious.

If anyone has any ideas, I would greatly appreciate it.

Thanks!

  • 写回答

1条回答 默认 最新

  • dousi4472 2012-07-28 07:02
    关注

    You need indeed to store data locally. It can be either a database or files.

    The set-up would go like that:

    • Have a PHP script that would

      1. Fetch the data associated to an API
      2. Store that result in a cache file
    • Have a CRON job that would run the above script 3 times a day

    • Have a frontend php page that will display the content of the cache files.

    If your server gets overloaded, you might consider caching the frontend php file to a static html file each time an API gets refreshed.

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

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大