为了账号安全,请及时绑定邮箱和手机立即绑定

调用未定义函数 GuzzleHttp\Psr7\get_message_body_summary()

调用未定义函数 GuzzleHttp\Psr7\get_message_body_summary()

PHP
函数式编程 2022-10-14 10:32:09
我正在尝试在 guzzlehttp 中执行 CURL 获取请求以检查用户是否存在于 CRM 中。每当我尝试执行请求时,标题中都会出现以下错误,我无法在线找到任何资源来解决这个特定问题。任何想法都会非常有帮助,如果您需要任何其他信息,请在评论中告诉我。包含的软件包:require(__DIR__ . "/../../vendor/autoload.php");require_once(__DIR__ . "/../../helpers/Validation.php");use Symfony\Component\Dotenv\Dotenv;use GuzzleHttp\Client;use GuzzleHttp\Request;use GuzzleHttp\RequestOptions;use GuzzleHttp\Psr7;use GuzzleHttp\Stream\Stream;use Drupal\Core\Site\Settings;// Load our environment variables$dotenv = new Dotenv();$dotenv->load(__DIR__ . "/../../.env");private function checkDuplicate() {  // If no errors we can submit the registrant  // \Drupal::logger('signup')->notice("access token", print_r($this->_accessToken, TRUE));  if(!$this->_errors) {    $checkNewUser = new Client();    try {      $options = [        'headers' => [        'Content-Type' => 'application/x-www-form-urlencoded',        'Authorization' => "Bearer " . $this->_accessToken      ],      "query" => '$filter=email%20eq%20"' .$this->_email . '"&$fields=Contact Key,First Name,Last Name'    ];    $result = $checkNewUser->get($_ENV['REST_API_URL'], $options);  } catch (RequestException $e) {    \Drupal::logger('signup')->error("error " . print_r($e->getRequest(), TRUE));    if ($e->hasResponse()) {      \Drupal::logger('signup')->error("error " . print_r($e->getRequest(), TRUE));      echo $e->getRequest() . "\n";      \Drupal::logger('signup')->error("error " . print_r($e->getResponse(), TRUE));    }  }}我有一个发布请求功能来获得一个正常工作的访问令牌。private function getAccessToken() {  try {    $requestAccessToken = new Client();    $options = [      'headers' => [        'Accept'     => 'application/json',      ],      "form_params" => [        "grant_type" => "client_credentials",         "client_id" => $_ENV["CLIENT_ID"],         "client_secret" => $_ENV["CLIENT_SECRET"]      ]    ];   
查看完整描述

1 回答

?
慕娘9325324

TA贡献1783条经验 获得超4个赞

该问题是由于 drupal-8 直接支持 guzzlehttp 引起的,导致与通过 composer 安装的包发生冲突。

删除 guzzle 的作曲家库并使用以下文档后: https ://www.drupal.org/docs/8/modules/http-client-manager/introduction


查看完整回答
反对 回复 2022-10-14
  • 1 回答
  • 0 关注
  • 64 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信