我需要在Symfony2项目上实现Bitbucket授权。我正在使用HWIOAuthBundle和Guzzle构建请求。为了获取电子邮件,我需要从https://bitbucket.org/api/1.0/users/{accountname}/emails获得json响应。但每次都会收到以下错误信息:
客户端错误响应 [url] https://bitbucket.org/api/1.0/users/{accountname}/emails [status code] 401 [reason phrase] UNAUTHORIZED"
但我已经在Bitbucket进行了授权。这是我的代码:
$url = 'https://bitbucket.org/api/1.0/users/'.$response->getUsername().'/emails';
$client = new Client();
$request = $client->createRequest('GET', $url);
$emails = $client->send($request);