InvalidArgumentException:URI必须是Guzzle中的字符串或UriInterface [关闭]

问题描述 投票:-1回答:2

当我从drupal 8站点发送以下代码时,我得到了如上所述的guzzle错误:

 $url="https://mywebsite.com/index.php";
 $client = \Drupal::httpClient();
 $client->setDefaultOption( array('verify' ,false));
 $post_data = $form_state->cleanValues()->getValues();

 $request = $client->post($url, $post_data);
guzzle
2个回答
0
投票

这一行导致它认为这是URL。当我把它拿出来时,它可以正常工作

$client->setDefaultOption(array('verify', false));

-1
投票

基本上,它应该工作(因为$url显然是一个字符串)。

如果没有,检查异常的堆栈跟踪(是这个调用还是其他?)。

并提供Guzzle版本。

© www.soinside.com 2019 - 2024. All rights reserved.