PHP POST-запрос к AWS шлюзу без скручивания - PullRequest
0 голосов
/ 20 марта 2020

Я пытаюсь сделать http-запрос к API-шлюзу aws без использования каких-либо библиотек php. Я проверил это в среде windows, и она работает, когда я перемещаю ее на мое встроенное устройство Linux. Я получаю сообщение "Не удалось открыть поток: невозможно найти транспортный сокет" ssl ".

Глядя на другой пост, я включил "extension = php_openssl.dll" в php .ini

Будучи новичком в php, и ему нужно, чтобы он был чистым php, это лучший способ go об этом?

Код:

$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)
...