How to get the particular data set from curl response - php
I'm trying to get the rcmDriverAgesInfo data from this
curl 'https://apis.rentalcarmanager.com/booking/v3.1/API_KEY/step2/0/5/17_11_2021/11_00/5/23_11_2021/11_00/2/0/-/-?apikey=API_KEY' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0' -H 'Accept: image/webp,*/*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Connection: keep-alive' -H 'Cookie: PHPSESSID=dksko0e9vkcuggi7lk7o94eaq1' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: Trailers'
And This is my code
<?
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://apis.rentalcarmanager.com/booking/v3.1/API_KEY=/step2/0/5/25_10_2021/11_00/5/30_10_2021/11_00/2/0/-/-?apikey=API_KEY=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30000,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
// Set Here Your Requesred Headers
'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0',
'Accept: image/webp,*/*',
'Content-Type: application/json',
'charset=UTF-8',
'Accept-Language: en-US,en;q=0.5',
'Connection: keep-alive',
'Cookie: PHPSESSID=dksko0e9vkcuggi7lk7o94eaq1',
'Pragma: no-cache',
'Cache-Control: no-cache',
),
)
);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
print_r($response,1);
This is curl output:
rcmLocationInfo = [{"id":"13","location":"ADELAIDE - 192 ONKAPARINGA VALLEY RD, WOODSIDE","webdefault":"False","pickupavailable":"True","dropoffavailable":"True","flightnoreqd":"False","noticerequired":"2","daysquotevalid":"7","officeopeningtime":"09:00","officeclosingtime":"16:00","afterhourbooking":"True","unattendeddropoffs":"True","minimunage":"18","afterhourfeeid":"309","unattendeddropofffeesid":"0","phone":"0417 816 649","email":"woodside#deluxecamper.com.au","minbookingday":"0"},{"id":"4","location":"AIRLIE BEACH - 1678 SHUTE HARBOUR RD","webdefault":"False","pickupavailable":"True","dropoffavailable":"True","flightnoreqd":"False","noticerequired":"0","daysquotevalid":"7","officeopeningtime":"09:00","officeclosingtime":"16:00","afterhourbooking":"True","unattendeddropoffs":"True","minimunage":"18","afterhourfeeid":"309","unattendeddropofffeesid":"0","phone":"0749483415","email":"tropicaccounts#whitsunday.net.au","minbookingday":"0"},{"id":"2","location":"BRISBANE - 40 FRENCH STREET EAGLE FARM","webdefault":"False","pickupavailable":"True","dropoffavailable":"True","flightnoreqd":"False","noticerequired":"0","daysquotevalid":"7","officeopeningtime":"09:00","officeclosingtime":"16:00","afterhourbooking":"True","unattendeddropoffs":"True","minimunage":"18","afterhourfeeid":"309","unattendeddropofffeesid":"0","phone":"07 5575 5400","email":"info#fivestarcarrentals.com.au","minbookingday":"0"},{"id":"1","location":"CAIRNS - 440 SHERIDAN STREET CAIRNS","webdefault":"True","pickupavailable":"True","dropoffavailable":"True","flightnoreqd":"False","noticerequired":"0","daysquotevalid":"7","officeopeningtime":"09:00","officeclosingtime":"16:00","afterhourbooking":"True","unattendeddropoffs":"True","minimunage":"18","afterhourfeeid":"309","unattendeddropofffeesid":"0","phone":"+6140813100","email":"sales#campermanaustralia.com","minbookingday":"0"},{"id":"12","location":"GOLDCOAST - 2/11 Northview St,Mermaid Wt","webdefault":"False","pickupavailable":"True","dropoffavailable":"True","flightnoreqd":"False","noticerequired":"0","daysquotevalid":"7","officeopeningtime":"09:00","officeclosingtime":"16:00","afterhourbooking":"True","unattendeddropoffs":"True","minimunage":"18","afterhourfeeid":"309","unattendeddropofffeesid":"0","phone":"(07) 5572 0600","email":"enquiries#surfersrentacar.com.au","minbookingday":"0"},{"id":"6","location":"MELB - 273 Elizabeth Street Coburg","webdefault":"False","pickupavailable":"True","dropoffavailable":"True","flightnoreqd":"False","noticerequired":"0","daysquotevalid":"7","officeopeningtime":"09:00","officeclosingtime":"16:00","afterhourbooking":"True","unattendeddropoffs":"True","minimunage":"18","afterhourfeeid":"309","unattendeddropofffeesid":"0","phone":"0393542945","email":"jpantonmotors#bigpond.com","minbookingday":"0"},{"id":"5","location":"SYDNEY - 23-25 ERSKINE RD CARINGBAH","webdefault":"False","pickupavailable":"True","dropoffavailable":"True","flightnoreqd":"False","noticerequired":"0","daysquotevalid":"7","officeopeningtime":"09:00","officeclosingtime":"14:00","afterhourbooking":"True","unattendeddropoffs":"True","minimunage":"18","afterhourfeeid":"309","unattendeddropofffeesid":"0","phone":"02 9540 5066","email":"sales#getacarrentals.com","minbookingday":"0"},{"id":"3","location":"TOWNSVILLE - 167 Mount Low Parkway, MOUNT LOW, QLD","webdefault":"False","pickupavailable":"True","dropoffavailable":"True","flightnoreqd":"False","noticerequired":"0","daysquotevalid":"7","officeopeningtime":"09:00","officeclosingtime":"16:00","afterhourbooking":"True","unattendeddropoffs":"True","minimunage":"18","afterhourfeeid":"309","unattendeddropofffeesid":"0","phone":"0407191437","email":"sales#campermanaustralia.com","minbookingday":"0"}];
rcmOfficeTimes = [{"locid":"1","wd":"1","afterhour":"True","unattended":"True","openingtime":"00:00","closingtime":"00:00","amstart":"00:00","amend":"23:55","pmstart":"00:00","pmend":"00:00","startpickup":"00:00","endpickup":"00:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"1","wd":"2","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"1","wd":"3","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"1","wd":"4","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"1","wd":"5","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"1","wd":"6","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"1","wd":"7","afterhour":"True","unattended":"True","openingtime":"00:00","closingtime":"00:00","amstart":"00:00","amend":"00:00","pmstart":"00:00","pmend":"00:00","startpickup":"00:00","endpickup":"00:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"2","wd":"1","afterhour":"True","unattended":"True","openingtime":"00:00","closingtime":"00:00","amstart":"00:00","amend":"23:55","pmstart":"00:00","pmend":"00:00","startpickup":"00:00","endpickup":"00:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"2","wd":"2","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"2","wd":"3","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"2","wd":"4","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"2","wd":"5","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"2","wd":"6","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"2","wd":"7","afterhour":"True","unattended":"True","openingtime":"08:30","closingtime":"11:00","amstart":"00:00","amend":"08:25","pmstart":"11:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"3","wd":"1","afterhour":"True","unattended":"True","openingtime":"00:00","closingtime":"00:00","amstart":"00:00","amend":"23:55","pmstart":"00:00","pmend":"00:00","startpickup":"00:00","endpickup":"00:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"3","wd":"2","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"3","wd":"3","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"3","wd":"4","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"3","wd":"5","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"3","wd":"6","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"3","wd":"7","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"12:00","amstart":"00:00","amend":"00:00","pmstart":"12:00","pmend":"15:00","startpickup":"00:00","endpickup":"15:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"4","wd":"1","afterhour":"True","unattended":"True","openingtime":"00:00","closingtime":"00:00","amstart":"00:00","amend":"23:55","pmstart":"00:00","pmend":"00:00","startpickup":"00:00","endpickup":"00:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"4","wd":"2","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"4","wd":"3","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"4","wd":"4","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"4","wd":"5","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"4","wd":"6","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"4","wd":"7","afterhour":"True","unattended":"True","openingtime":"08:30","closingtime":"11:00","amstart":"00:00","amend":"08:25","pmstart":"11:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"5","wd":"1","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"12:00","amstart":"00:00","amend":"00:00","pmstart":"00:00","pmend":"00:00","startpickup":"00:00","endpickup":"00:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"5","wd":"2","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"5","wd":"3","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"5","wd":"4","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"5","wd":"5","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"19:00","startpickup":"00:00","endpickup":"19:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"5","wd":"6","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:00","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"5","wd":"7","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"12:00","amstart":"00:00","amend":"00:00","pmstart":"12:00","pmend":"15:00","startpickup":"00:00","endpickup":"15:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"6","wd":"1","afterhour":"True","unattended":"True","openingtime":"00:00","closingtime":"00:00","amstart":"00:00","amend":"23:55","pmstart":"00:00","pmend":"00:00","startpickup":"00:00","endpickup":"00:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"6","wd":"2","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"18:00","startpickup":"00:00","endpickup":"18:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"6","wd":"3","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"18:00","startpickup":"00:00","endpickup":"18:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"6","wd":"4","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"18:00","startpickup":"00:00","endpickup":"18:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"6","wd":"5","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"18:00","startpickup":"00:00","endpickup":"18:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"6","wd":"6","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"00:00","pmstart":"16:00","pmend":"18:00","startpickup":"00:00","endpickup":"18:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"6","wd":"7","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"12:00","amstart":"00:00","amend":"00:00","pmstart":"12:00","pmend":"15:00","startpickup":"00:00","endpickup":"15:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"12","wd":"1","afterhour":"True","unattended":"True","openingtime":"00:00","closingtime":"00:00","amstart":"00:00","amend":"23:55","pmstart":"00:00","pmend":"00:00","startpickup":"00:00","endpickup":"00:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"12","wd":"2","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"12","wd":"3","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"12","wd":"4","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"12","wd":"5","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"12","wd":"6","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"12","wd":"7","afterhour":"True","unattended":"True","openingtime":"08:30","closingtime":"11:00","amstart":"00:00","amend":"08:25","pmstart":"11:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"13","wd":"1","afterhour":"True","unattended":"True","openingtime":"00:00","closingtime":"00:00","amstart":"00:00","amend":"23:55","pmstart":"00:00","pmend":"00:00","startpickup":"00:00","endpickup":"00:00","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"13","wd":"2","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"13","wd":"3","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"13","wd":"4","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"13","wd":"5","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"13","wd":"6","afterhour":"True","unattended":"True","openingtime":"09:00","closingtime":"16:00","amstart":"00:00","amend":"08:55","pmstart":"16:00","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"},{"locid":"13","wd":"7","afterhour":"True","unattended":"True","openingtime":"08:30","closingtime":"11:00","amstart":"00:00","amend":"08:25","pmstart":"11:05","pmend":"23:55","startpickup":"00:00","endpickup":"23:55","startdropoff":"00:00","enddropoff":"24:00"}];
rcmCategoryTypeInfo = [{"id":"6","categorytype":"CamperVan","ordering":"c","rentingtype":"True","raimage":"","rate12hour":"True","ratepernight":""}];
rcmDriverAgesInfo = [{"id":"10","driverage":"18","defaultage":"False"},{"id":"2","driverage":"19","defaultage":"False"},{"id":"3","driverage":"20","defaultage":"False"},{"id":"4","driverage":"21+","defaultage":"False"}];
rcmLocationFees = [{"cattypeid":"6","loctypeid":"1","loctype":"pickup","locationid":"5","currencyname":"","currencysymbol":"$","locdate":"25 Oct 2021","loctime":"11:00","dwname":"Monday","days4minbookingdaycheck":"6","location":"SYDNEY - 23-25 ERSKINE RD CARINGBAH","locdateloctime":"11-Oct-2021","tstavailable":"1","ierrorcode":"0","availablemsg":"","iafterhourpickup":"0","iafterhourdropoff":"0","tstminbookingday":"0","flightnoreqd":"False"},{"cattypeid":"6","loctypeid":"2","loctype":"dropoff","locationid":"5","currencyname":"","currencysymbol":"$","locdate":"30 Oct 2021","loctime":"11:00","dwname":"Saturday","days4minbookingdaycheck":"6","location":"SYDNEY - 23-25 ERSKINE RD CARINGBAH","locdateloctime":"11-Oct-2021","tstavailable":"1","ierrorcode":"0","availablemsg":"","iafterhourpickup":"0","iafterhourdropoff":"0","tstminbookingday":"0","flightnoreqd":"False"}];
rcmAvailableCarDetails = [];
rcmMandatoryFees = [{"cattypeid":"6","column1":"MandatoryFees","id":"414","locationid":"5","vehiclesizeid":"2","numofdays":"6","qty":"1","fees":"70.0000","name":"Administration Fee","type":"Fixed","maxprice":"0.0000","fee_cost":"70.00","stampduty":"False","gst":"True","percentagetotalcost":"False","excessfee":"0.0000","merchantfee":"False","fromage":"0","toage":"0","qtyapply":"False","extradesc":"","extradesc1":"","extradesc2":"","extradesc3":""},{"cattypeid":"6","column1":"MandatoryFees","id":"414","locationid":"5","vehiclesizeid":"4","numofdays":"6","qty":"1","fees":"70.0000","name":"Administration Fee","type":"Fixed","maxprice":"0.0000","fee_cost":"70.00","stampduty":"False","gst":"True","percentagetotalcost":"False","excessfee":"0.0000","merchantfee":"False","fromage":"0","toage":"0","qtyapply":"False","extradesc":"","extradesc1":"","extradesc2":"","extradesc3":""},{"cattypeid":"6","column1":"MandatoryFees","id":"414","locationid":"5","vehiclesizeid":"5","numofdays":"6","qty":"1","fees":"70.0000","name":"Administration Fee","type":"Fixed","maxprice":"0.0000","fee_cost":"70.00","stampduty":"False","gst":"True","percentagetotalcost":"False","excessfee":"0.0000","merchantfee":"False","fromage":"0","toage":"0","qtyapply":"False","extradesc":"","extradesc1":"","extradesc2":"","extradesc3":""},{"cattypeid":"6","column1":"MandatoryFees","id":"414","locationid":"5","vehiclesizeid":"27","numofdays":"6","qty":"1","fees":"70.0000","name":"Administration Fee","type":"Fixed","maxprice":"0.0000","fee_cost":"70.00","stampduty":"False","gst":"True","percentagetotalcost":"False","excessfee":"0.0000","merchantfee":"False","fromage":"0","toage":"0","qtyapply":"False","extradesc":"","extradesc1":"","extradesc2":"","extradesc3":""},{"cattypeid":"6","column1":"MandatoryFees","id":"414","locationid":"5","vehiclesizeid":"30","numofdays":"6","qty":"1","fees":"70.0000","name":"Administration Fee","type":"Fixed","maxprice":"0.0000","fee_cost":"70.00","stampduty":"False","gst":"True","percentagetotalcost":"False","excessfee":"0.0000","merchantfee":"False","fromage":"0","toage":"0","qtyapply":"False","extradesc":"","extradesc1":"","extradesc2":"","extradesc3":""},{"cattypeid":"6","column1":"MandatoryFees","id":"414","locationid":"5","vehiclesizeid":"31","numofdays":"6","qty":"1","fees":"70.0000","name":"Administration Fee","type":"Fixed","maxprice":"0.0000","fee_cost":"70.00","stampduty":"False","gst":"True","percentagetotalcost":"False","excessfee":"0.0000","merchantfee":"False","fromage":"0","toage":"0","qtyapply":"False","extradesc":"","extradesc1":"","extradesc2":"","extradesc3":""},{"cattypeid":"6","column1":"MandatoryFees","id":"414","locationid":"5","vehiclesizeid":"35","numofdays":"6","qty":"1","fees":"70.0000","name":"Administration Fee","type":"Fixed","maxprice":"0.0000","fee_cost":"70.00","stampduty":"False","gst":"True","percentagetotalcost":"False","excessfee":"0.0000","merchantfee":"False","fromage":"0","toage":"0","qtyapply":"False","extradesc":"","extradesc1":"","extradesc2":"","extradesc3":""}];
rcmOptionalFees = [];
rcmInsuranceOptions = [];
rcmKmCharges = [];
rcmTaxInclusive=true;rcmTaxRate=0.100;rcmStateTax=0.000;
rcmErrors = [];
rcmStep2Ready("","","");
But I just want only rcmOfficeTimes data
[{"id":"10","driverage":"18","defaultage":"False"},{"id":"2","driverage":"19","defaultage":"False"},{"id":"3","driverage":"20","defaultage":"False"},{"id":"4","driverage":"21+","defaultage":"False"}]
I need the rcmOfficeTimes dataset from this response data. Anyone can help me
Related
Postman exported curl not works but in Postman Works
i have a problem whit postman i am develope a connectio to a api and i am experience a strange unsolved error. I am try to post a excel file to a server , in Postman all woprks fine and im able to upload the file whit no problem. But if i export the code generated , they return a " Invalid File" error. i have try all and no way to find what is going wrong here <?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://eiffel-monorepo-stock.aws.paris.cl/stock/import/7707ecb8-ebc8-4f37-86f6-4a658a46becc', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => array('file'=> new CURLFILE('/home/alakazan/Descargas/stock_1666535230.xlsx')), CURLOPT_HTTPHEADER => array( 'Host: [[[EXCLUDED DATA]]]', 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:106.0) Gecko/20100101 Firefox/106.0', 'Accept: application/json, text/plain, */*', 'Accept-Language: es,es-CL;q=0.8,en-US;q=0.5,en;q=0.3', 'Accept-Encoding: gzip, deflate, br', 'Referer: [[[EXCLUDED DATA]]]', 'Authorization: Bearer [[[EXCLUDED DATA]]], 'Content-Type: multipart/form-data; boundary=---------------------------83496323188075087905603769295', 'Content-Length: 15844', 'Origin: [[[EXCLUDED DATA]]]', 'Connection: keep-alive', 'Sec-Fetch-Dest: empty', 'Sec-Fetch-Mode: no-cors', 'Sec-Fetch-Site: same-site', 'Pragma: no-cache', 'Cache-Control: no-cache' ), )); $response = curl_exec($curl); curl_close($curl); echo $response; I try to upload using console and error are Invalid file :( {"statusCode":400,"error":true,"message":"Invalid File"}
Post request working in Postman but not in php code(SSL_ERROR_SYSCALL)
I'm trying to make a simple curl post request using PHP code snippet from Postman. But when I'm trying to run it I get the following error: "OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054" In postman the request is working fine and I do get the json results. Here's an inline link for postman header and the postman body My php code is the following: $curl = curl_init(); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false); curl_setopt_array($curl, array( CURLOPT_URL => "https://www.oglasnik.hr/ajax/getNearBy", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 500, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"classifiedId\"\r\n\r\n3996266\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"bounds\"\r\n\r\n{\"east\":16.00793838500977,\"west\":15.977039337158205,\"north\":45.78652940999985,\"south\":45.773958941535355}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", CURLOPT_HTTPHEADER => array( "Accept: application/json, text/javascript, */*; q=0.01", "Accept-Encoding: gzip, deflate, br", "Accept-Language: en-US,en;q=0.9", "Cache-Control: no-cache", "Connection: keep-alive", "Content-Length: 384", "Content-Type: application/x-www-form-urlencoded", "Cookie: cookieconsent_status=allow; ogl_visits^[0^]=a5cbwGRWU7YEC1LP6tKOVOzf6GIZzyU7dbry64BfNak4xygExIAj^%^2FkGWQ5azKqmznEHJVCF4ZfufdAaCugfPjPi8vX7CB8Gs^%^2F3OdX5RVvYjyfWKHUHboChkYfbURk6Ly", "Host: www.oglasnik.hr", "Origin: https://www.oglasnik.hr", "Postman-Token: 60eebbd3-ed26-4aed-ae32-f190353ce333,aa32ad1d-55c6-4fa6-928e-3309a497c36a", "Referer: https://www.oglasnik.hr/stanovi-najam/novi-zagreb-bundek-2-sobni-stan-55-m2-oglas-3996266", "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36", "X-Requested-With: XMLHttpRequest", "cache-control: no-cache", "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } UPDATE: With the tip from #Andrew I changed the CURLOPT_HTTPHEADER to: CURLOPT_HTTPHEADER => array( "Accept: application/json, text/javascript, */*; q=0.01", "Accept-Encoding: gzip, deflate, br", "Accept-Language: en-US,en;q=0.9", "Cache-Control: no-cache", "Connection: keep-alive", "Content-Type: application/x-www-form-urlencoded", "Cookie: cookieconsent_status=allow; ogl_visits^[0^]=a5cbwGRWU7YEC1LP6tKOVOzf6GIZzyU7dbry64BfNak4xygExIAj^%^2FkGWQ5azKqmznEHJVCF4ZfufdAaCugfPjPi8vX7CB8Gs^%^2F3OdX5RVvYjyfWKHUHboChkYfbURk6Ly", "Host: www.oglasnik.hr", "Origin: https://www.oglasnik.hr", "Referer: https://www.oglasnik.hr/stanovi-najam/novi-zagreb-bundek-2-sobni-stan-55-m2-oglas-3996266", "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36", "X-Requested-With: XMLHttpRequest", "cache-control: no-cache", "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" ) And i'm getting the response! Unfortunately its only { "status": false } As it looks like I'm sending my post parameters wrong. Problem is that I need to send one integer parameter and one string as json, currently trying like this: $bounds = [ "east" => 16.00793838500977, "west" =>15.977039337158205, "north" =>45.78652940999985, "south" =>45.773958941535355 ]; $params = [ "classifiedId" => 3996266, "bounds" => json_encode($bounds) ]; and adding this parameter in curl_setopt_array: CURLOPT_POSTFIELDS => $params Final update: It worked! As #Andrew stated in the comments it worked using: CURLOPT_POSTFIELDS => http_build_query($params) so the final header is: curl_setopt_array($curl, array( CURLOPT_URL => "https://www.oglasnik.hr/ajax/getNearBy", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => http_build_query($params), CURLINFO_HEADER_OUT => true, CURLOPT_HTTPHEADER => array( "Accept: application/json, text/javascript, */*; q=0.01", "Accept-Encoding: gzip, deflate, br", "Accept-Language: en-US,en;q=0.9", "Cache-Control: no-cache", "Connection: keep-alive", "Content-Type: application/x-www-form-urlencoded", "Cookie: cookieconsent_status=allow; ogl_visits^[0^]=a5cbwGRWU7YEC1LP6tKOVOzf6GIZzyU7dbry64BfNak4xygExIAj^%^2FkGWQ5azKqmznEHJVCF4ZfufdAaCugfPjPi8vX7CB8Gs^%^2F3OdX5RVvYjyfWKHUHboChkYfbURk6Ly", "Host: www.oglasnik.hr", "Origin: https://www.oglasnik.hr", "Referer: https://www.oglasnik.hr/stanovi-najam/novi-zagreb-bundek-2-sobni-stan-55-m2-oglas-3996266", "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36", "X-Requested-With: XMLHttpRequest", "cache-control: no-cache", "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" ), ));
How do i convert this cURL command into PHP code? And what is "Request Payload"?
So, I was inspecting the network while I'm uploading an JPG image. A copy as a curl command : curl "https://admin-official.line.me/11702069/home/api/objects" -H "Origin: https://admin-official.line.me" -H "Accept-Encoding: gzip, deflate, br" -H "Accept-Language: en-US,en;q=0.9,id;q=0.8,de-DE;q=0.7,de;q=0.6" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36" -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBv1B9k1i89zlgjnA" -H "Accept: */*" -H "Referer: https://admin-official.line.me/11702069/home/send/" -H "Cookie: tzoffset=-420; _trmccid=6b030cba93d9db09; _ga=GA1.2.1058855825.1526457491; _gid=GA1.2.814129237.1526457491; ldsuid=CiDum1r75zWBJ3f7oLqRAg==; _trmcdisabled2=-1; _trmcuser=^{^\^"id^\^":^\^"^\^"^}; _ga=GA1.3.1058855825.1526457491; _gid=GA1.3.814129237.1526457491; plack_session_localaccount=XXX; minesota=XXX; minesota2=XXX-jdT5f_x10ov7Re12NliQw_zFyIe9osY4oOOc2Rxdy1gMyBhXbKdPmnpA2LHB9VhvlqlL_4hkeSNQK5SgU; plack_session=6cd2e4790ae9990303ea54f7f35b305fba801dc0; _trmcsession=^{^\^"id^\^":^\^"b8ba0724^\^",^\^"path^\^":^\^"/11702069/home/send/^\^",^\^"query^\^":^\^"^\^",^\^"time^\^":1526735963213,^\^"_dice^\^":0.09452730791211028^}; __try__=1526737592637; _trmcpage=/11702069/home/send/" -H "Connection: keep-alive" --data-binary ^"------WebKitFormBoundaryBv1B9k1i89zlgjnA^ Content-Disposition: form-data; name=^\^"file^\^"; filename=^\^"alpen.jpg^\^"^ Content-Type: image/jpeg^ ^ ^ ------WebKitFormBoundaryBv1B9k1i89zlgjnA^ Content-Disposition: form-data; name=^\^"csrf_token^\^"^ ^ vJiSf8AZPpAvqCp0JQtrNOMgrZRtrDpa1TEHbYLz^ ------WebKitFormBoundaryBv1B9k1i89zlgjnA--^ ^" --compressed I've never seen this before, i'm not an expert at curl. But I'm using curl to PHP coverter, but it's not working in this case. EDIT : here's what I've tried. <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://admin-official.line.me/11702069/home/api/objects"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, array("file" => "#".realpath('test.jpg'), "csrf_token" => $split2[0])); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate'); $headers = array(); $headers[] = "Origin: https://admin-official.line.me"; $headers[] = "Accept-Encoding: gzip, deflate, br"; $headers[] = "Accept-Language: en-US,en;q=0.9,id;q=0.8,de-DE;q=0.7,de;q=0.6"; $headers[] = "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36"; $headers[] = "Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBv1B9k1i89zlgjnA"; $headers[] = "Accept: */*"; $headers[] = "Referer: https://admin-official.line.me/11702069/home/send/"; $headers[] = 'Cookie: tzoffset=-420; _trmccid=6b030cba93d9db09; _ga=GA1.2.1058855825.1526457491; _gid=GA1.2.814129237.1526457491; ldsuid=CiDum1r75zWBJ3f7oLqRAg==; _trmcdisabled2=-1; _trmcuser={"id":""}; _ga=GA1.3.1058855825.1526457491; _gid=GA1.3.814129237.1526457491; plack_session_localaccount=XXX; minesota=XXX; minesota2=XXX; plack_session=XXX; _trmcsession={"id":"b8ba0724","path":"/11702069/home/send/","query":"","time":1526735963213,"_dice":0.09452730791211028}; __try__=1526737592637; _trmcpage=/11702069/home/send/'; $headers[] = "Connection: keep-alive"; curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $result = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } curl_close ($ch); echo $result; ?>
the "request payload" is the request body. a HTTP request is split into 2 parts, the headers, and the body (and Chrome calls the body for the request payload here, not sure if that's an official name, or just the whim of a chromium dev) anyway, you're using the # method, which was discouraged as of PHP 5.5, disabled-by-default in php 5.6, and completely removed in PHP7. use CURLFile instead, eg: curl_setopt($ch, CURLOPT_POSTFIELDS, array( "file" => new CURLFile('test.jpg'), "csrf_token" => $split2[0] )); also, don't set the Accept-Encoding header manually. you specify gzip, deflate, br, and curl doesn't support br, and depending on how libcurl was compiled, might not even support gzip/deflate (although it usually does), remove that. also, set CURLOPT_ENCODING to emptystring, and curl will list all encodings it was built to support (which is usually gzip and deflate, but is not guaranteed to be) also, when using the # or CURLFile method, don't set the Content-Type header manually, because if curl's boundary doesn't match what you set in the Content-Type header, the server won't be able to read the request properly. curl will set this header for you, if you don't override it, so don't.
Figure it out using Postman. $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://admin-official.line.me/11702069/home/api/objects", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => array( "csrf_token" => $split2[0], "file" => new CURLFile("test.jpg") ), //CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"csrf_token\"\r\n\r\nETukCyg_-OM72cZ0MuAyunvvy4cb8Cx2QqoP41T7\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", CURLOPT_HTTPHEADER => array( "Accept: */*", "Accept-Encoding: gzip, deflate, br", "Accept-Language: en-US,en;q=0.9,id;q=0.8,de-DE;q=0.7,de;q=0.6", "Cache-Control: no-cache", "Connection: keep-alive", "Content-Type: multipart/form-data", "Cookie: tzoffset=-420; _trmccid=6b030cba93d9db09; _ga=GA1.2.1058855825.1526457491; _gid=GA1.2.814129237.1526457491; ldsuid=CiDum1r75zWBJ3f7oLqRAg==; _trmcdisabled2=-1; _trmcuser=^{^\^id^^:^\^^^^}; _ga=GA1.3.1058855825.1526457491; _gid=GA1.3.814129237.1526457491; plack_session_localaccount=COOKIE; minesota=COOKIE; minesota2=COOKIE; _trmcsession=^{^\^id^^:^\^36b6efe6^^,^\^path^^:^\^/11702069/home/send/^^,^\^query^^:^\^^^,^\^time^^:1526880852499,^\^_dice^^:0.4099096438552394^}; plack_session=519cce226206bd15cba86f2153c9dc91a56df4fb; _trmcpage=/11702069/home/send/; __try__=1526881572577", "Origin: https://admin-official.line.me", "Postman-Token: 8b9dc9c8-166a-4c50-93c4-b16ca72d72dc", "Referer: https://admin-official.line.me/11702069/home/send/", "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36", //"content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" ), )); curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookie.txt'); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
How to post data with cURL?
I want to return the response as url instead boolean. I looks header from browser and match it but it only return boolean (1). Is there some options missing? <?php $ch = curl_init(); $url = 'http://www.tusfiles.net/anfossy50rrd'; // Post field and value $post = array( 'op' => 'download2', 'id' => 'anfossy50rrd', 'rand' => 'q56tfpiklusrizipkforyjqsykxzqlsi7ur3hyi', 'referer' => '', 'method_free' => '', 'method_premium' => '', 'down_script' => '1' ); its the header $headers = [ 'Host: www.tusfiles.net', 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0', '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', 'Cache-Control: no-cache', 'Content-Type: application/x-www-form-urlencoded; charset=utf-8', 'Referer: http://www.tusfiles.net/anfossy50rrd', 'Cookie: lang=english; login=lynxpravoka; xfss=; aff=2513158; __atuvc=17%7C36; __atuvs=57cf088127fd55f9004; cookiescriptaccept=visit', 'Connection: keep-alive', 'Upgrade-Insecure-Requests: 1' ]; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS,$post); $server_output = curl_exec ($ch); print_r($server_output); ?>
You need to use something like this: curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'X-Header-1: value1', 'X-Header-2: value2' )); Or you can also build an array where the key is the header name and the value is of course the header value. It would look something like this: $headers = array( 'Host' => 'www.tusfiles.net', 'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0' ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); http://www.php.net/manual/en/function.curl-setopt.php
the problem is that the server returns a HTTP/1.1 302 Found HTTP redirect, expecting you to send the request to the "found" URL. but because you do not have CURLOPT_FOLLOWLOCATION - nor do you manually handle redirects (nor read the redirect headers at all), you do not follow the redirect. enable CURLOPT_FOLLOWLOCATION , and you should get the response. also, you should practically never give the 'Accept-Encoding: gzip, deflate', header manually with curl. if curl was not actually compiled with gzip or deflate and the server decides to use it, the transfer will fail, furthermore, if, in the future, both the server and curl supports an even better transfer encoding, it won't be used because you explicitly said only gzip/deflate was supported. instead, make curl give all supported encodings automatically, by giving an empty string '' to CURLOPT_ENCODING. and a protip: in the future, to debug why curl transfers isn't working as expected, enable CURLOPT_VERBOSE
Execute cUrl request
I'm new to php & cUrl's so I was wondering if someone knows how to get the following command executed using php. curl "http://www.mywebsite.com/index.php?action=confirm" -H "Origin: http://www.mywebsite.com" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" -H "Cache-Control: max-age=0" -H "Referer: http://www.mywebsite.com/index.php?action=confirm" -H "Connection: keep-alive" --data "confirmed=yes&id=14&from=&to=TestPerson" --compressed Thanks in advance and sorry if this beginner stuff. I'm just trying to learn
Rewrite like this.. <?php $ch = curl_init(); $curlconf = array( CURLOPT_URL => "http://www.mywebsite.com/index.php?action=confirm", CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => array( 'confirmed' => 'yes', 'id' => 14, 'from'=>'', 'to'=>'TestPerson', ) ); curl_setopt_array($ch, $curlconf); $result = curl_exec($ch); echo $result; curl_close($ch);
You have a PHP extension for that : http://www.php.net/manual/fr/curl.examples-basic.php