php - Guzzle:魔术请求方法需要一个 URI 和可选的选项数组
问题描述
我正在使用https://github.com/golincode/sharepoint-oauth-app-client它已过时并使用 Guzzle 版本 5。我的 Symfony 应用程序使用 Guzzle 6。我正在尝试更新过时的代码以使用 Guzzle 6 但是我遇到以下错误:
Magic request methods require a URI and optional options array
控制器中的代码。
$settings = [
'site' => [
'resource' => '00000000-0000-ffff-0000-000000000000/example.sharepoint.com@09g7c3b0-f0d4-416d-39a7-09671ab91f64',
'client_id' => '52848cad-bc13-4d69-a371-30deff17bb4d/example.com@09g7c3b0-f0d4-416d-39a7-09671ab91f64',
'secret' => 'YzcZQ7N4lTeK5COin/nmNRG5kkL35gAW1scrum5mXVgE=',
]
];
// create a SharePoint Site instance
$site = SPSite::create('https://example.sharepoint.com/sites/mySite/', $settings);
SPSite.php 创建函数
public static function create($url, array $settings = [])
{
// ensure we have a trailing slash
if (is_string($url)) {
$url = sprintf('%s/', rtrim($url, '/'));
}
$settings = array_replace_recursive($settings, [
'site' => [], // SharePoint Site configuration
'http' => [ // Guzzle HTTP Client configuration
'base_url' => $url,
],
]);
$http = new Client($settings['http']);
return new static($http, $settings['site']);
}
Client.php 调用函数
public function __call($method, $args)
{
if (count($args) < 1) {
throw new \InvalidArgumentException('Magic request methods require a URI and optional options array');
}
$uri = $args[0];
$opts = isset($args[1]) ? $args[1] : [];
return substr($method, -5) === 'Async'
? $this->requestAsync(substr($method, 0, -5), $uri, $opts)
: $this->request($method, $uri, $opts);
}
我不知道版本 5 和 6 之间发生了什么变化,这使得该代码不再工作。有人有线索吗?
解决方案
推荐阅读
- eclipse - Eclipse(C++),有没有办法禁止编辑具有特定结尾的文件?
- java - 在android中为从高度X落下的球绘制高度v/s时间图
- laravel - 在共享主机上托管时出现 Laravel 错误
- java - 解析多部分 servlet 请求失败;直播意外结束
- java - 如何在 java 中将“2020-03-11 16:27:31”格式转换为“2020-02-24T11:04:52+00:00”格式
- wso2 - WSO2 EI - API 上下文无法识别
- javascript - 流式使用备忘录钩子
- parallel-processing - 将功能分配给多个任务
- c# - Windows 服务无法访问网络驱动器路径 asp.net
- r - 如何将 xlsx 文件读入 R 并将其转换为 tsibble 对象?