Reputation: 537
I use this curl to post data:
$ch_request=curl_init();
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $request);
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($curl);
curl_close ($curl);
But i check that the data isn't post, how can i know that? be cause i write it in a error_log, the system response with OK if the data was posted but i recive nothing when i check my error_log.
The URL that i try to post is generated automatically and is something like this:
https://precise-line.com/request?api_key=23894thfpoiq10f&user_id=508958644&delivery_type=Programado&route=Eje+1+norte&street_number=40&neighborhood=Centro&locality=Mexico&administrative_area_level_1=Distrito+Federal&postal_code=00650&country=Mexico&latlng=19.3596892%2C-99.2788723&destination-route=Calle+pinco+85%2C+Int.+1%2C+Col.+Florida%2C+Del.+%C3%81lvaro+Obreg%C3%B3n&destination-street_number=&destination-neighborhood=&destination-locality=Ciudad+de+M%C3%A9xico&destination-administrative_area_level=Distrito+Federal&destination-postal_code=01080&destination-country=Mexico&destination-latlng=19.3627808%2C-99.1757137&customer_email=ink_design%40hotmail.com&customer_phone=56581111¬ification_email=¬es=Orden%3A+%2316652%2C+Cliente%3A+Said+Pe%C3%B1a+Amezcua%2C+Productos%3A+DEVIL+MAY+CRY+DEFINITIVE+EDITION+1%2C+&dispatch=True
This is how I generate my url:
$api_key= '23894thfpoiq10f';
$user_id= '508958644';
if ($shipping == $program){
$delivery_type = 'Programado';
}
if ($shipping == $express){
$delivery_type = '99minutos';
}
$latlng = '19.4165176%2C-99.1544438';
$customer_email= urlencode($email);
$destination_route= urlencode(implode(',' , array($address1,$address2)));
$destination_locality= urlencode($city);
$destination_administrative_area_level= urlencode($province);
$destination_postal_code= urlencode($zip);
$d_latlng= urlencode(implode(',', array($latitude,$longitude)));
$customer_phone= urlencode($phone);
$nombre = 'Cliente: '.implode(' ',array($first_name,$last_name));
$orden = 'Orden: '.$name;
$request = "https://precise-line.com/request?";
$request.= "api_key=".$api_key."&";
$request.= "user_id=".$user_id."&";
$request.= "delivery_type=".$delivery_type."&";
$request.= "route=Av+Cuauhtemoc&";"street_number=187&";
$request.= "neighborhood=Roma+Norte&";
$request.= "locality=Mexico&";
$request.= "administrative_area_level_1=Distrito+Federal&";
$request.= "postal_code=06700&";
$request.= "country=Mexico&";
$request.= "latlng=".$latlng."&";
$request.= "destination-route=".$destination_route."&";
$request.= "destination-street_number=&";
$request.= "destination-neighborhood=&";
$request.= "destination-locality=".$destination_locality."&";
$request.= "destination-administrative_area_level=".$destination_administrative_area_level."&";
$request.= "destination-postal_code=".$destination_postal_code."&";
$request.= "destination-country=Mexico&";
$request.= "destination-latlng=".$d_latlng."&";
$request.= "customer_email=".$customer_email."&";
$request.= "customer_phone=".$customer_phone."&";
$request.= "notification_email=&";
$request.= "notes=".$notes."&";
$request.= "dispatch=True";
Upvotes: 2
Views: 52
Reputation: 537
I found the solution and it was in the SSL version, i wrote 3 and the version to solved my problem is 1, but thank you for everyone who helps me
Upvotes: 0
Reputation: 3778
You need to add 2 more options to curl:
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$params should be an associative array of the params you want like:
$params = array('api_key'=>'abcde')
Also, the value of $request
in curl_setopt($curl, CURLOPT_URL, $request);
should be the base url without the params like https://precise-line/request
Upvotes: 1