使用HTTP和承载器的客户端Rest Php

使用HTTP和承载器的客户端Rest Php,php,rest,codeigniter,guzzlehttp,Php,Rest,Codeigniter,Guzzlehttp,Hi-im使用GuzzleHttp使用Rest API 我的代码: 但当我每次调用函数时,都会显示: {“错误”:“未经授权”,“错误描述”:“访问被拒绝”} 如果我尝试与邮递员,它的作品 我做错了什么 try{ $accessToken="Bearer xxxxxxxxxxxxx"; $client = new GuzzleHttp\Client(); $request=$client->request('GET', 'https://api.mocaplatform.co

Hi-im使用GuzzleHttp使用Rest API 我的代码:

但当我每次调用函数时,都会显示:

{“错误”:“未经授权”,“错误描述”:“访问被拒绝”}

如果我尝试与邮递员,它的作品

我做错了什么

try{
 $accessToken="Bearer xxxxxxxxxxxxx";
  $client = new GuzzleHttp\Client();

  $request=$client->request('GET', 'https://api.mocaplatform.com/v2/meta/domains/');
 $request->addHeader('Authorization',  $accessToken);
  $query = $request->getQuery();
  $query->set('oauth_token', $accessToken);
  $response = $request->send();
    $response = $response->json();
    return $response;

}
   catch (GuzzleHttp\Exception\BadResponseException $e) {
    #guzzle repose for future use
    $response = $e->getResponse();
    $responseBodyAsString = $response->getBody()->getContents();
    print_r($responseBodyAsString);

}
return 'hola';
}