我使用此卷曲发布数据:
$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);
但是我检查数据不发布,我怎么知道呢?因为我把它写在error_log中,系统响应如果数据已发布就OK,但是当我检查我的error_log时我没有回复。
我尝试发布的网址会自动生成,如下所示:
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
这是我生成我的网址的方式:
$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";
答案 0 :(得分:1)
您需要再添加2个卷曲选项:
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$ params应该是你想要的参数的关联数组:
$params = array('api_key'=>'abcde')
此外,$request
中curl_setopt($curl, CURLOPT_URL, $request);
的值应该是没有像https://precise-line/request
答案 1 :(得分:0)
我找到了解决方案并且它是在SSL版本中,我写了3并且解决我的问题的版本是1,但是感谢所有帮助我的人