首页 > 解决方案 > 如何在 Shopware 中使用 restClient 调用带有令牌的 URL?

问题描述

我正在尝试调用外部 url。我的网址看起来像这样。

curl -X GET "https://api.manu.th/v1/list" -H "accept: application/json" -H "Token: token_number" 

现在我无法使用 Shopware 6 来实现它。到目前为止,我已经尝试了以下代码行。

$this->restClient = new Client();
$request = new Request(
            'GET',
            "https://api.manu.th/v1/list",
            [
                'Token' => 'token_number'
            ],
            ['Content-Type' => 'application/json']
        );

        $response = $this->restClient->send($request);

        $body = json_decode($response->getBody()->getContents(), true);

这是回归我is not callable: Invalid resource type: array", "meta": {

有人可以帮我吗?

标签: symfony4shopware

解决方案


推荐阅读