cordoprod Posted August 15, 2009 Share Posted August 15, 2009 I am trying to make an iPhone application for buses in Norway. If I am going to do that I need to cURL the contents from the bus company in Norway which offer the data. Here is the site to do that: http://hafas.websrv6.reiseinfo.no/bin/dev/nri/query.exe/on?L=vs_rutebok I want to autopost all the fields via cURL. Here is my code so far: <?PHP //extract data from the post extract($_POST); $from1 = 1; $from = "skarpengland"; $to1 = 1; $to = "vennesla"; $time = "23.00"; $date = "16.08.09"; //set POST variables $url = 'http://hafas.websrv6.reiseinfo.no/bin/dev/nri/query.exe/on?L=vs_rutebok&OK#focus'; $fields = array( 'REQ0JourneyStopsS0A'=>urlencode($from1), 'REQ0JourneyStopsS0G'=>urlencode($from), 'REQ0JourneyStopsZ0A'=>urlencode($to1), 'REQ0JourneyStopsZ0G'=>urlencode($to), 'REQ0JourneyDate'=>urlencode($date), 'REQ0JourneyTime'=>urlencode($time), ); //url-ify the data for the POST foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch); ?> I haven't added all the fields yet, but my problem is that when you click the search button on the original page, it should check if the place (to and from) exists. It doesn't do that on my script. It just fills out the fields and i have to click search manually. Link to comment https://forums.phpfreaks.com/topic/170439-curl-and-php/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.