CURL to Guzzle有标题问题


CURL to Guzzle having Header issue

我正在尝试在guzzle上设置授权头。我有我的请求成功地工作与以下CURL代码:

function callApi($url,$accesstoken)
{
    $headr = array();
    $headr[] = 'Authorization:Bearer '.$accesstoken;
    //cURL starts
    $crl = curl_init();
    curl_setopt($crl, CURLOPT_URL, $url);
    curl_setopt($crl, CURLOPT_HTTPHEADER,$headr);
    curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($crl, CURLOPT_HTTPGET,true);
    $reply = curl_exec($crl);
    //error handling for cURL
    if ($reply === false) {
        print_r('Curl error: ' . curl_error($crl));
       return false;
    }
    curl_close($crl);
    return $reply;
}

我怎么能用这个Guzzle代码拿到401。我尝试了很多不同的方法来设置标题,但都没有成功。

public function __construct()
    {
        $this->config = 'Config::get('services.******');
        $this->client = new Client([
            'base_uri' => 'https://*******/' . $this->config['merchant_id']
        ]);
    }
    public function getInventoryItems()
    {
        $response = $this->client->get('items', [
            'headers' => [
                'Authorization' => 'Bearer' . $this->config['token']
            ]
        ]);
        return json_decode($response->getBody());
    }
'Authorization' => 'Bearer' . $this->config['token']
应该

'Authorization' => 'Bearer ' . $this->config['token']