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

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题