Php 使用curl和ssl发布数据时出错

Php 使用curl和ssl发布数据时出错,php,ssl,curl,Php,Ssl,Curl,我使用此curl发布数据: $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发布数据:

$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);
但我检查数据是否未发布,我怎么知道?由于我将其写入错误日志,如果数据已发布,系统将以OK响应,但在检查错误日志时,我未收到任何信息

我尝试发布的URL是自动生成的,如下所示:

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&notification_email=&notes=Orden%3A+%2316652%2C+Cliente%3A+Said+Pe%C3%B1a+Amezcua%2C+Productos%3A+DEVIL+MAY+CRY+DEFINITIVE+EDITION+1%2C+&dispatch=True
这是我生成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";

您需要为curl添加另外两个选项:

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$params应该是所需参数的关联数组,如:

$params = array('api_key'=>'abcde')

另外,
curl\u setopt($curl,CURLOPT\u URL,$request)中
$request
的值
应该是没有参数的基本url,如
https://precise-line/request

我找到了解决方案,它是在SSL版本中,我写了3,解决我问题的版本是1,但是感谢所有帮助我的人

为什么不使用Postman来测试您使用的API呢。你会知道你提出的请求是否正确,以及你得到的回复。在您的情况下,我认为您应该执行GET请求,因为您的URL包含所有数据。是的,如果我使用Postman来测试URL,则数据是post,但如果没有它,我就没有响应!所以,如果您使用Postman得到正确的响应,请单击generate code并查看缺少哪些curl选项。那会有帮助的。但是几天前我发布的卷曲有效,但是从上周五到现在卷曲无效如果这个解决方案解决了你的问题,请接受回答。对不起,我看到解决方案在其他方面。。。它是在ssl版本是1不是3像我的例子!