douzheyo2617 2018-08-17 20:41
浏览 99
已采纳

如何安排API调用和数据库更新

I have a php web app and have written a class that effectively invokes an API which requests data from our 3rd party membership system database. The API returns the data and saves the XML into a file (as it's a very large data set). This xml file is then parsed and I upload some of that data into my web application's database.

It takes approximately 4 hours for the API to return all of the data. Currently I invoke this process by clicking a button on my web page. However, I want to automate the process and schedule it to run every so often but have no idea where to begin or what to even Google. The web app runs on a Windows server which is running xammp. Any help is much appreciated.

I have managed to create a .bat file to execute my php script but I now get several errors in the CMD windows stating that it failed to open any of the files that I include in my script file:

My script file is:

<?php

include '../config.php';
include (ROOT.'/includes/my_session.php');
include (ROOT.'/model/dao.php');
include (ROOT.'/model/miller_api.php');
include (ROOT.'/model/branch_db.php');

$a = new miller_api;

$k = $a->apiRequest('key');
$a->apiRequest('branch', $k);

And here is a screen shot of the errors I am getting: CMD errors

  • 写回答

1条回答 默认 最新

  • douqian6315 2018-08-18 01:01
    关注

    It is quite simple. Create a run.bat file with the following command

    C:\xampp\php\php.exe C:\xampp\htdocs\SCRIPTFOLDER\SCRIPT.php
    

    And schedule the run.bat file using windows Task Scheduler

    https://www.techsupportalert.com/content/how-schedule-programs-run-automatically-windows-7.htm

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

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏