-1

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...?
Roman
  • 131
  • 2
  • 10

1 Answers1

1

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

Community
  • 1
  • 1
Apul Gupta
  • 3,044
  • 3
  • 22
  • 30
  • Thank you for your link. I try to understand the code, but cannot. Sorry, could you please give me a code snippet? – Roman Oct 08 '14 at 18:53
  • @Roman, if you'd say what exactly you want to do with the link, we could help better... – baao Oct 08 '14 at 19:03
  • @Michael: I grab data from my personal weather station (xml file) and want to post it to wunderground.com (http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol). In this documentation is the information, how to post data via URL. I can generate the URL (as a link) but cannot send it from a cron-job. I have no idea how to do. – Roman Oct 08 '14 at 19:17
  • @Apul: Thank you, your snippet helped me to find out how to do! Thanks! – Roman Oct 08 '14 at 19:46