PHP - Need Help With Ssl Curl - Flight Schedule
I need help to get flight schedule from http://www.sriwijayaair.co.id/id but always error using curl to access ssl.
here are my code: <?php $headers = array( "User-Agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 GTB7.1 (.NET CLR 3.5.30729)", "Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language=en-us,en;q=0.5", "Accept-Encoding=gzip,deflate", "Accept-Charset=ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Keep-Alive=1150", "Connection=keep-alive", "Referer=http://www.sriwijayaair.co.id/id", "Cookie=language=in; location=id; dest=home; __utma=260465999.1394002812.1293106375.1293106375.1293106375.1; __utmb=260465999.1.10.1293106375; __utmc=260465999; __utmz=260465999.1293106375.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)", "Content-Type=application/x-www-form-urlencoded", "Content-Length=121", "POSTDATA=isReturn=false&from=CGK&to=MES&departDate1=30-&departDate2=11-2010&adult=1&child=0&infant=0&returndaterange=0&Submit=Cari" ); // do access to sriwijaya air $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "https://booking.sriwijayaair.co.id/b2c/AvailabilityServlet"); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($curl, CURLOPT_COOKIEJAR, "cookie.txt"); //curl_setopt($curl, CURLOPT_POSTFIELDS, "isReturn=false&from=CGK&to=MES&departDate1=22&departDate2=01-2011&adult=1&child=0&infant=0&returndaterange=0&Submit=Cari"); $curlData = curl_exec($curl); print_r($curlData); curl_close($curl); ?> any help will be appreciate, thanks Similar Tutorials<?php function extractItem(&$array, $itemKey) { $data = array(); foreach($array[$itemKey] as $item) { $Id = $item['Id']; // get the id unset($item['Id']); // remove the id from item array $data[$Id] = $item; // set id as the key } unset($array[$itemKey]); // remove item from array. return $data; // return the new item array } // get the api parametures from setup url $country_code = $_GET['country']; $originplace = $_GET['strtplace']; $destination = $_GET['endplace']; $start_date = $_GET['startdate']; if(isset($_GET['enddate']) && $_GET['enddate']!=""){ $end_date = $_GET['enddate'];} $audult = $_GET['audult']; if(isset($_GET['child']) && $_GET['child']!=""){ $child = $_GET['child'];} if(isset($_GET['infent']) && $_GET['infent']!=""){ $infent = $_GET['infent'];} $class = $_GET['class']; if (!empty($_SERVER['HTTP_CLIENT_IP'])){ $ip=$_SERVER['HTTP_CLIENT_IP'];} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){ $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];} else{$ip=$_SERVER['REMOTE_ADDR'];} $xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=".$ip); $ip_curency = $xml->geoplugin_currencyCode ; $query = "&country=".$country_code; $query .= "¤cy=".$ip_curency; $query .= "&locale=en-GB"; $query .= "&originplace=".$originplace; $query .= "&destinationplace=".$destination; $query .= "&outbounddate=".$start_date; if(isset($end_date) && $end_date!=""){ $query .= "&inbounddate=".$end_date;} $query .= "&adults=".$audult; if(isset($child) && $child!=""){ $query .= "&children=".$child;} if(isset($infent) && $infent!=""){ $query .= "&infants=".$infent;} $query .="&locationschema=iata"; $query .="&cabinclass=".$class; $query .="&pagesize=10"; $apiParamsUrl = "http://partners.api.skyscanner.net/apiservices/pricing/v1.0/".$country_code."?apikey=SECRET".$query.""; $apiParamsStr = parse_url($apiParamsUrl, PHP_URL_QUERY); // get the query string parametures parse_str($apiParamsStr, $apiParamsArray); // parse into an array // the api url. First we need to request for a session $apiSessionUrl = 'http://partners.api.skyscanner.net/apiservices/pricing/v1.0'; //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $apiSessionUrl); curl_setopt($ch,CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Accept: application/json')); // make api return json data curl_setopt($ch,CURLOPT_POST, count($apiParamsArray)); // set how many fiels curl_setopt($ch,CURLOPT_POSTFIELDS, $apiParamsStr); // set the fields // caputre the headers curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HEADER, 1); //execute post $response = curl_exec($ch); // get the headers $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size); $body = substr($response, $header_size); //close connection curl_close($ch); // get the api session url preg_match('~Location: ([^\s]+)~', $header, $matches); $apiSessionUrl = $matches[1]; // add on the api key for the session $apiSessionUrl .= '?apiKey=' . $apiParamsArray['apikey']; // get the json data $data = file_get_contents($apiSessionUrl); // decode the json $array = json_decode($data, true); // dump json array printf('<pre>Poll Data %s</pre>', print_r($array, true)); //Itineraries $Agents = extractItem($array, 'Agents'); // get array of agents //... foreach ($array['Itineraries'] as $Itineraries) { foreach($Itineraries['PricingOptions'] as $Option) { echo "<b> Agents: </b> "; // loop over agents for current priceOption foreach($Option['Agents'] as $agentId) { echo $Agents[ $agentId ]['Name']. ', '; // echo the agent name that matches agentId. } echo " <br> price </b>",$Option['Price'] ,"<br />"; } } //Legs foreach ($array['Legs'] as $Leg) { echo "<b> Departure </b> " .$Leg['Departure'], " <br> <b>Arrival </b>",$Leg['Arrival'] ,"<br />"; } //Carriers foreach ($array['Carriers'] as $Carrier) { echo "<b> Name </b> " .$Carrier['Name'], " <br> Image </b>",$Carrier['ImageUrl'] ,"<br />"; } //Places foreach ($array['Places'] as $Place) { echo "<b> Code </b> " .$Place['Code'], " <br> Name </b>",$Place['Name'] ,"<br />"; } ?>Hi professionals I am trying to extract the correct information from a flights API It was working until I added in the function. Now I just see the word Poll Data on my screen is there something I am missing here (code attached) Thanks Hey everyone, Im writing some code that has to work out a route based on linking airports and output all the flights it takes to get there, tried searching just dont really know what to search for The data table looks like this ID, Origin, Destination, DatetimeDeparting, DatetimeArriving, Price 1, BKK, CNX, 2010-10-14 12:00:00, 2010-10-14 14:00:00, 125 2, STN, BKK, 2010-10-13 18:00:00, 2010-10-13 22:00:00, 300 etc. What is the easiest way of working out the path from STN to CNX via BKK? UPDATE: Just to make it more interesting there will be instances where there is more than 1 path eg. STN -> KUL -> BKK -> CNX Hi, This may be the wrong way to do things but I am fairly new to this. I have a mysql database which I store some jobs I run. I usually use schedule tasks for this but was wondering if I could do this more efficiently in PHP. I have a table with days of the week comma seperated and then a column with a time and then a column with the name of the job. I basically need something to kick off a job at a given time on a certain day. If someone can point me in the right direction it would be appreciated and I can usually crack on from there I currently have the below code that reads a database to find what time a staff member is scheduled for work and what day. The below code works fine however on the same day it print lets say they work more then one hour it would show Sunday 2a - 3a, Sunday 3a - 4a, Sunday 4a - 5a ..... and so on I would just like it to simply put Sunday 2a - 5a skipping the extra output. $dayname = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); $shifts = array(); $num=0; $days=0; for ($d = 0; $d <= 6; $d++) { $slot = mysql_fetch_array(mysql_query("SELECT * FROM rp_timetable WHERE day = '$dayname[$d]'")); for ($i = 1; $i <= 24; $i++) { $ap1 = "a"; $ap2 = "a"; if ($slot["$i"] == $eusername) { $one = $i-1; if($one >= 12) { $one = $i-13; if($one == 0) { $one = 12; } $ap1 = "p"; } $two = $i; if($two >= 12) { $two = $i-12; if($two == 0) { $two = 12; } $ap2 = "p"; } $shifts[$num] .= $dayname[$d].' '.$one.''.$ap1.' - '.$two.''.$ap2.' EST<br>'; $num++;}} } if($shifts[0] != NULL){ echo"<table><tr><td><strong>Air Shifts:</strong></td><td>"; for ($i = 0; $i <= $num; $i++) { if($i == 0) {echo $shifts[$i].'</td></tr>';} else {echo '<tr><td></td><td>'.$shifts[$i].'</td></tr>';} }} print"</table>"; I'm new here so I say hallo to everyone I have to implement bus time table in this way: Every bus drives every second day from the day chosen. Let's say: If xx bus goes every second day from 23rd February to 30th June to Spain (23rd, 25th, 27th...), How can I check if let's say on 14th May there is bus to Spain? I started with odd and even numbers: if it starts from the even day than there is array of months with number of days, but what if Feb has 29days (every 4th year) instead of 28... I'm totally confused here. In database I have rows: start date, end date and bus name. Is there any other way of implementing this? I am trying to write a simple method of displaying our meetings schedule for North Idaho Area Narcotics Anonymous it pulls from a MySQL database and I want it to look like this: COEUR D'ALENE Sunday: Group 1 Name Time Group 2 Name Time Group 3 Name Time Monday: Group 1 Name Time Group 2 Name Time POST FALLS Sunday: Group 1 Name Time Ok so my problem is I dont know how to make php create the heading only if there are meetings in that heading so if there are no meetings in POST FALLS then it wont make a list for post falls or if there are no meetings in POST FALLS on Sunday then it wont show the SUNDAY heading. This way it will be maintenance free page just add/delete meetings in the database then go from there. Each meeting name will be a link to an ID corresponding to the unique ID in the database so you click it then read all the info on that meeting. It will be a way for NA members to view the schedule from their mobile phones easily. I have written loops but nothing that would leave out a heading based on lack of a given entry. Any help would be most appreciated. Thank you!!! Chad Hi everyone I need some help on how to go about designing a script for a high school. It is for teachers so that they can book periods for the computer lab, studio etc. I want it so when they go to the page it has this week with all the slots taken. What I'm having trouble with is I want them to also be able to go to any date they wish and bring up that weeks schedule because they need to be able to book in advance. Would anyone be able to explain a technique on how I can go about this Thanks in advance This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=342882.0 hello guys. i need to run a script automatically at scheduled date and time. i am sending bulk emails . i need to setup an email campaign, in such a way that i can schedule like daily, monthly or quarterly.. can u guys give few tips to get it done.. Hi there, I am working on a php project on my WAMP server where I have access to XML datafeed from xe.com once a day to get the Exchange rates. This xml datafeed is saved on my localhost as an archived copy. Now I would like to automatically access the fresh xml datafeed file from xe.com once a day and replace (or update) the xml file on my localhost to have the updated information (rates). How can I schedule this task automatically and make php access the updated xml file once a day. All comments and feedbacks are always welcomed Thank you! I've got a class schedule that spans two years and I would like to have the years as headers. startDate is unix date field. Here is existing code: $sql = "SELECT * FROM classOfferings, classes, instructors WHERE classes.classId = classOfferings.classId AND classOfferings.instructorId = instructors.instructorId AND classOfferings.startDate >= CURDATE() ORDER BY classOfferings.startDate"; if(! $retval ) { die('Could not get schedule: ' . mysql_error()); } while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) { echo "{$row['dates']}"; if ($row['hours'] != 0){ echo "</td> "; } else { echo "CANCELLED</td>"; } echo "<td class='cell2'>". "<a href='classDetail.php?seq={$row['seq']}'>{$row['title']}</a>". "{$row['days']}". "{$row['times']}". "<a href='instructorDetail.php?instructorId={$row['instructorId']}'>{$row['fName']} "." ". "{$row['lName']}</a></td>} echo "</td></tr></table></div>"; } I have database "raj" with table "pagination"
In table pagination have "id", "actualtime" and "created" field
id - auto_increment actualtime- varchar created- datetime
that looks like this CREATE TABLE pagination( id int auto_increment, actualtime varchar(55), created datetime )
I want to display all rows which are created on todays date and will display from today upto yesterday at 06:00 pm. after that the content will be refreshed based on based on a DATETIME field called 'created' that holds the date and time of each record's creation.
this is my query to fetch rows but it display value after 06:00 pm on yesterday but i want to display all data before 06:00 pm from currentdate. After 06:00 pm data will be refreshed and clear. plz help me......
SELECT actualtime FROM pagination WHERE created BETWEEN date_add(date_sub(curdate(), INTERVAL 1 day), INTERVAL 18 hour) AND curdate()";
good day dear community, i am workin on a Curl loop to fetch multiple pages: i have some examples - and a question: Example: If we want to get information from 3 sites with CURL we can do it like so: $list[1] = "http://www.example1.com"; $list[2] = "ftp://example.com"; $list[3] = "http://www.example2.com"; After creating the list of links we should initialize the cURL multi handle and adding the cURL handles. $curlHandle = curl_multi_init(); for ($i = 1;$i <= 3; $i++) $curl[$i] = addHandle($curlHandle,$list[$i]); Now we should execute the cURL multi handle retrive the content from the sub handles that we added to the cURL multi handle. ExecHandle($curlHandle); for ($i = 1;$i <= 3; $i++) { $text[$i] = curl_multi_getcontent ($curl[$i]); echo $text[$i]; } In the end we should release the handles from the cURL multi handle by calling curl_multi_remove_handle and close the cURL multi handle! If we want to another Fetch of sites with cURL-Multi - since this is the most pretty way to do it! Well I am not sure bout the string concatenation. How to do it - Note I want to fetch several hundred pages: see the some details for this target-server sites - /(I have to create a loop over several hundred sites). * siteone.example/?show_subsite=9009 * siteone.example/?show_subsite=9742 * siteone.example/?show_subsite=9871 .... and so on and so forth Question: How to appy this loop into the array of the curl-multi? <?php /************************************\ * Multi interface in PHP with curl * * Requires PHP 5.0, Apache 2.0 and * * Curl * ************************************* * Writen By Cyborg 19671897 * * Bugfixed by Jeremy Ellman * \***********************************/ $urls = array( "siteone", "sitetwo", "sitethree" ); $mh = curl_multi_init(); foreach ($urls as $i => $url) { $conn[$i]=curl_init($url); curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);//return data as string curl_setopt($conn[$i],CURLOPT_FOLLOWLOCATION,1);//follow redirects curl_setopt($conn[$i],CURLOPT_MAXREDIRS,2);//maximum redirects curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,10);//timeout curl_multi_add_handle ($mh,$conn[$i]); } do { $n=curl_multi_exec($mh,$active); } while ($active); foreach ($urls as $i => $url) { $res[$i]=curl_multi_getcontent($conn[$i]); curl_multi_remove_handle($mh,$conn[$i]); curl_close($conn[$i]); } curl_multi_close($mh); print_r($res); ?> I look forward to your ideas. Hi Folks, I'm creating an equipment reservation system for a client. Every reservation has an equipmentID, ReservationDate, StartTime, EndTime. So, basically my script searches existing records for a given date and EquipmentID. I'm having trouble with how best to approach validation on new reservations to ensure there are no conflicts. Lets say two existing reservations for a given date/equipment are found. One reservation has a startTime of 8AM and endTime of 9AM. The second has a startTime of 12PM and endTime of 3PM. Is there a simple way to check if the user's submitted values for StartTime and EndTime conflict with existing reservations? Any input would be greatly appreciated! Thanks! -John Hi all, I am wondering what the best way to do this is... Take GoDaddy for example, if your domain is about to expire you will get an automatic email. I am wanting to do something similar, If someone orders a Soap Dispenser, I want to send an email (if they accept to receiving emails on the order) each month asking/reminding them to top up on soap. I have been reading but cant find anything adequate, I have seen something about Cron Jobs, but never heard of this before, please could you point me in the right direction. Thanks in advance. Peter I have a few questions that deals with cURL. Question #1 Lets say I'm using cURL to fill out a form with multiple pages. Is cURL able to navigate through each page of the form retaining all the previous pages information until I reach the last page, then submit it all without losing any data? I'm pretty sure this is possible, I just can't seem to find any tutorials or help with it. Question #2 Lets just say I was trying to fill out a form with a CAPTCHA (which obviously I can't get past). Is there a way to display the web page with all the other information filled out, and just leave the CAPTCHA blank to be manually inputted? It would be greatly appreciated if you are able to point me in the right direction! Thanks in advance! Hello, I'm new to lot of this and especially php. I'm having hard time with one of my app that I created. If you go to ticketlawyerorlando.com/sms5.html and you try to send text, (which is set to go to only one number (mine)) than I get error code from php that is supposed to curl it. Error: Warning: curl_setopt() [function.curl-setopt]: Invalid curl configuration option in /home/content/s/j/1/sj10mil/html/ticketlawyerorlando/sms5.php on line 10 SUCCESS My Html code is : Code: [Select] <html> <body> <br/> <form action="sms5.php" method="post"> <b>Your Phone Number:</b> <input type="text" name="to" /> <br/> <b>Message:</b> <input type="text" name="msg" /> <br/> <input type="submit" /> </form> </body> </html> My sms5.php code is : Code: [Select] <html> <head> <title>SMS STATUS</title> </head> <body> <?php //print $to; //print $msg; $curl_handle=curl_init(); curl_setopt($curl_handle, CURLOPT_GET,1); curl_setopt($curl_handle, CURLOPT_URL,'https://api.tropo.com/1.0/sessions?to=3213314633&msg=test4&token=010fc32265db5444bbf84e92bd28f1887395ce3ade6cf69e1424d586add66b17bdc7c1d8061803f1c2319d66'); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,5); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,2); $response = curl_exec($curl_handle); $code = curl_getinfo($curl_handle,CURLINFO_HTTP_CODE); //print $code; //print $response; print "SUCCESS"; curl_close($curl_handle); ?> </body> </html> In my php, the URL that's being curled, in the part where it says "test4" that should be actual message that is typed in the form but I don't know what kind of parameter to insert there in order for it to send message that's written, it always sends message "test4". Please, if you could help me I would greatly appreciate it. Thank You so much again. MOD EDIT: code tags added What exactly is cURL? What are alternatives to it? I am reading some code for submitting payment info to a Payment Gateway and trying to understand how cURL plays into this?! Thanks, Debbie can someone help me create a cURL for this? i think its a get method, right? Access it including the GET parameters and make sure that settings are also follows. Dispatcher URL: http://website.net/gw/dispatcher.woof GET Parameters: RRN is the random reference number SRC is the access code (i.e 2336) DST is the recipient of the message (i.e. 639209547958) MSG is the actual reply message up to 420 characters, including non printable characters. KYWRD is the primary keyword (i.e. hello) need help. thanks.. this is my current code <?php //getting the value of RRN $rrn=urlencode($_GET['rrn']); //getting the value of MSG $msg=urlencode($_GET['msg']); //getting the value of DST $dst=urlencode($_GET['dst']); //getting the value of SRC $src=urlencode($_GET['src']); //setting up the value of KYWRD $kywrd = urlencode('KEYWORD'); //assuming that the dst here is 2336 $aw = "haha"; $str= "?src=".$dst."&dst=".$src."&msg=".$aw."&rrn=".$rrn."&kywrd=".$kywrd; print $str; $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,' http://www.website.net/gw/dispatcher.woof'.$str); curl_exec($ch); curl_close($ch); ?> Is this correct? Thanks |