duanma8207 2014-10-08 18:29
浏览 34
已采纳

从Cron自动提交由PHP脚本生成的URL

I wrote a small script, grabbing data from xml file. I need some of this xml data to generate a URL. I'm looking for a function, how to 'submit' (auto send) this generated URL. I don't use a form, the script is executed by a cron job and works 'hands-free'.

Here are some parts of my script. Thank you for your help!

<?php
$xml=simplexml_load_file("xml.xml");

// MAKE SOME VARIABLES FROM XML
$GUST = $xml->gust;

// I CAN GENERATE A WORKING LINK...
echo "<a href='http://anywhere&gust=".$GUST."&TR=T'>WORKING LINK</a>";

   // BUT I I TRY TO SEND THIS GENERATED URL FROM A CRON-JOB.
   //... no idea...?
  • 写回答

1条回答 默认 最新

  • dtf24224 2014-10-08 18:35
    关注

    You can use CURL to post on url.

    An example is here:

    Passing $_POST values with cURL

    $dataToPost = array('name' => 'Ross');
    $handle = curl_init($urlToPostAt);
    curl_setopt($handle, CURLOPT_POST, true);
    curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
    curl_exec($handle);
    

    Please note curl should be enabled in your php.ini

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

报告相同问题?

悬赏问题

  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作