具有社交 VK 的 HWIOAuthBundle 'Cannot register an account.'
HWIOAuthBundle 'Cannot register an account.' with social VK
我在使用 HWIOAuthBundle
和 vk.com
时遇到问题,一切正常,但前一段时间我发现面对错误,在使用 vk.com
进行 oAuth 之后
'Cannot register an account.'
我找到了这个地方vendor/hwi/oauth-bundle/Controller/ConnectController.php:106
if (!($error instanceof AccountNotLinkedException) || (time() - $key > 300)) {
// todo: fix this
throw new \Exception('Cannot register an account.');
}
但不明白为什么会这样。我尝试使用其他应用程序,但无济于事。也许有人知道我为什么会收到这个错误?
看起来问题是由最近的更新引起的:https://vk.com/dev/version_update
您应该在此处添加 "v" 参数:
https://github.com/hwi/HWIOAuthBundle/blob/6401d53617816257208b8df384bdc47d2d701bf5/OAuth/ResourceOwner/VkontakteResourceOwner.php#L46
您必须在 vendor/hwi/oauth-bundle/OAuth/ResourceOwner/VkontakteResourceOwner 中指定版本 3.0 api VK。php
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
$url = $this->normalizeUrl($this->options['infos_url'], array(
'access_token' => $accessToken['access_token'],
'fields' => $this->options['fields'],
'name_case' => $this->options['name_case'],
'v' => '3.0'
));
$content = $this->doGetUserInformationRequest($url)->getContent();
$response = $this->getUserResponse();
$response->setResponse($content);
$response->setResourceOwner($this);
$response->setOAuthToken(new OAuthToken($accessToken));
$content = $response->getResponse();
$content['email'] = isset($accessToken['email']) ? $accessToken['email'] : null;
if (isset($content['screen_name'])) {
$content['nickname'] = $content['screen_name'];
} else {
$content['nickname'] = isset($content['nickname']) ? $content['nickname'] : null;
}
$response->setResponse($content);
return $response;
}
我在使用 HWIOAuthBundle
和 vk.com
时遇到问题,一切正常,但前一段时间我发现面对错误,在使用 vk.com
'Cannot register an account.'
我找到了这个地方vendor/hwi/oauth-bundle/Controller/ConnectController.php:106
if (!($error instanceof AccountNotLinkedException) || (time() - $key > 300)) {
// todo: fix this
throw new \Exception('Cannot register an account.');
}
但不明白为什么会这样。我尝试使用其他应用程序,但无济于事。也许有人知道我为什么会收到这个错误?
看起来问题是由最近的更新引起的:https://vk.com/dev/version_update
您应该在此处添加 "v" 参数: https://github.com/hwi/HWIOAuthBundle/blob/6401d53617816257208b8df384bdc47d2d701bf5/OAuth/ResourceOwner/VkontakteResourceOwner.php#L46
您必须在 vendor/hwi/oauth-bundle/OAuth/ResourceOwner/VkontakteResourceOwner 中指定版本 3.0 api VK。php
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
$url = $this->normalizeUrl($this->options['infos_url'], array(
'access_token' => $accessToken['access_token'],
'fields' => $this->options['fields'],
'name_case' => $this->options['name_case'],
'v' => '3.0'
));
$content = $this->doGetUserInformationRequest($url)->getContent();
$response = $this->getUserResponse();
$response->setResponse($content);
$response->setResourceOwner($this);
$response->setOAuthToken(new OAuthToken($accessToken));
$content = $response->getResponse();
$content['email'] = isset($accessToken['email']) ? $accessToken['email'] : null;
if (isset($content['screen_name'])) {
$content['nickname'] = $content['screen_name'];
} else {
$content['nickname'] = isset($content['nickname']) ? $content['nickname'] : null;
}
$response->setResponse($content);
return $response;
}