1

我对使用 PEAR 的 HttpRequest2 进行 HTTP 请求没有任何问题,但是当我在 HTTPS url 中有一个 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:在 C:\wamp\pear\HTTP\Request2\Adapter\Socket.php中的第1020行 aaaaaa;文本对齐:居中;字体粗细:粗体;">异常跟踪 cccccc;宽度:20px;字体粗细:粗体;">#Function

style="text-align: center; background: #cccccc; font-weight: bold;">位置0HTTP_Request2_Response->__construct('', true, Object(Net_URL2))C:\wamp\pear\HTTP\Request2\Adapter \Socket.php:1020 1HTTP_Request2_Adapter_Socket->readResponse()C:\wamp\pear\HTTP\Request2\Adapter\Socket.php:136 2HTTP_Request2_Adapter_ in C:\wamp\pear\HTTP\Request2\Response.php 在第 215 行

任何形式的有用反馈将不胜感激


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

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

4

0 回答 0