PHP 5.4.12中HTTP_Request2的HTTPS请求错误

时间:2017-11-28 12:30:30

标签: php html api pear http-request2

我对使用PEAR的HttpRequest2进行HTTP请求没有任何问题,但是当我在HTTPS网址中有API时会出现此问题; 请注意我使用的是PHP 5.4。

<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';


$request = new HTTP_Request2('https://api.transavia.com/v3/routes/',
                             HTTP_Request2::METHOD_GET, array('use_brackets' => true));

$url = $request->getUrl();

// I tried removing SSL verification, hoping it would help, it did not.
$request->setConfig(array(
    'ssl_verify_peer'   => FALSE,
    'ssl_verify_host'   => FALSE
));

// Ignore first 2 Headers; those are tests from Postman, which work, meaning the APIKey and Variables are correct
$request->setHeader(array(
  'postman-token' => '2ab78460-4e01-de66-1b31-274362f34a3e',
  'cache-control' => 'no-cache',
  'apikey' => '24e555fe917a4762a6b462cbe177dcae'
));


$url->setQueryVariables(array(
    'Origin' => 'AMS',
    'Destination' => 'ACE'
));

// This will output a page with open bugs for Net_URL2 and HTTP_Request2
echo $request->send()->getBody();


?>

我得到的错误是

  

(!)致命错误:未捕获    HTTP_Request2_MessageException :in    C:\ wamp \ pear \ HTTP \ Request2 \ Adapter \ Socket.php 在线    1020      AAAAAA; text-align:center; font-weight:bold;“&gt;异常跟踪      CCCCCC;宽度:20像素; font-weight:bold;“&gt; #Function      

style =“text-align:center; background:#cccccc; font-weight:   粗体;“&gt;位置0HTTP_Request2_Response-&gt; __ construct('',true,   对象(Net_URL2))C:\瓦帕\梨\ HTTP \请求2 \适配器\ Socket.php:1020   1HTTP_Request2_Adapter_Socket-&GT; readResponse()C:\瓦帕\梨\ HTTP \请求2 \适配器\ Socket.php:136   2HTTP_Request2_Adapter_   在第215行的C:\ wamp \ pear \ HTTP \ Request2 \ Response.php

任何有用的反馈都将受到高度赞赏

编辑日志: @twicejr; 错误:响应格式错误:HvTTP / 1.1 200 OK

每次刷新时,“HvTTP”中的“v”都在不断变化。它在b,v,¥等之间切换。

0 个答案:

没有答案