12 require_once dirname(dirname(__FILE__)) .
'/EOAuth2Service.php';
20 protected $name =
'odnoklassniki';
21 protected $title =
'Odnoklassniki';
22 protected $type =
'OAuth';
23 protected $jsArguments = array(
'popup' => array(
'width' => 680,
'height' => 500));
25 protected $client_id =
'';
26 protected $client_secret =
'';
27 protected $client_public =
'';
28 protected $scope =
'';
29 protected $providerOptions = array(
30 'authorize' =>
'http://www.odnoklassniki.ru/oauth/authorize',
31 'access_token' =>
'http://api.odnoklassniki.ru/oauth/token.do',
35 $sig = strtolower(md5(
'application_key='.$this->client_public.
'client_id='.$this->client_id.
'format=JSONmethod=users.getCurrentUser'.md5($this->access_token.$this->client_secret)));
37 $info = $this->
makeRequest(
'http://api.odnoklassniki.ru/fb.do', array(
39 'method' =>
'users.getCurrentUser',
42 'application_key' => $this->client_public,
43 'client_id' => $this->client_id,
44 'access_token' => $this->access_token,
48 $this->attributes[
'id'] = $info->uid;
49 $this->attributes[
'name'] = $info->first_name.
' '.$info->last_name;
53 return $this->providerOptions[
'access_token'];
58 'client_id' => $this->client_id,
59 'client_secret' => $this->client_secret,
60 'grant_type' =>
'authorization_code',
62 'redirect_uri' => $this->
getState(
'redirect_uri'),
64 $url = $this->
getTokenUrl($code).
'?client_id='.$this->client_id.
'&client_secret='.$this->client_secret.
'&redirect_uri='.urlencode($this->
getState(
'redirect_uri')).
'&code='.$code.
'&grant_type=authorization_code';
65 $result = $this->
makeRequest($url, array(
'data' => $params));
66 return $result->access_token;
70 $this->
setState(
'redirect_uri', $redirect_uri);
72 if (isset($_GET[
'js']))
73 $url .=
'&display=popup';
83 if (isset($json->error)) {
85 'code' => $json->error_code,
86 'message' => $json->error_description,