到AWS网关的PHP POST请求不卷曲

时间:2020-03-20 14:24:17

标签: php api http request stream

我试图在不使用任何PHP库的情况下向aws API网关发出http发布请求。我已经在Windows环境中对此进行了测试,并将其移到Linux嵌入式设备上时,它可以正常工作。我收到“无法打开流:找不到套接字传输” ssl”的消息。

看看其他帖子,我在php.ini中启用了“ extension = php_openssl.dll”

成为php的新手,并要求它是纯php,这是解决此问题的最佳方法吗?

代码:

$w = stream_get_wrappers();
echo 'openssl: ',  extension_loaded  ('openssl') ? 'yes':'no', "\n";
echo 'http wrapper: ', in_array('http', $w) ? 'yes':'no', "\n";
echo 'https wrapper: ', in_array('https', $w) ? 'yes':'no', "\n";
echo 'wrappers: ', var_dump($w);

//request password and next password.
$opts = array(
    'http' => array(
        'method' => 'GET',
        'header' => "Content-Type: application/json\r\n".
                    "x-api-key: **********************\r\n",
    )
);
$context  = stream_context_create($opts);
//this @ suppress the warning about a bad http call
$passwords = file_get_contents($RequestPassURL , false, $context);
var_dump($passwords);

输出:

openssl: no
http wrapper: yes
https wrapper: no
wrappers: array(6) {
  [0]=>
  string(3) "php"
  [1]=>
  string(4) "file"
  [2]=>
  string(4) "glob"
  [3]=>
  string(4) "data"
  [4]=>
  string(4) "http"
  [5]=>
  string(3) "ftp"
}

Warning: file_get_contents(http://AWSURL): failed to open stream: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? in /home/root/changPass on line 71
bool(false)

0 个答案:

没有答案