Commit 7b7a2df5 authored by Alex Ne's avatar Alex Ne

VK Service key Add

parent 12a985bf
......@@ -7,12 +7,12 @@ class Credentials {
/**
* @var mixed
*/
private $client_id, $client_secret, $api_version;
private $client_id, $client_secret, $api_version,$api_service_key;
/**
* @param $client_id
* @param $client_secret
*/
public function __construct($client_id, $client_secret, $api_version = "5.52") {
public function __construct($client_id, $client_secret, $api_version = "5.52", $api_service_key = false) {
if (is_numeric($client_id) && $client_id > 0) {
$this->client_id = $client_id;
} else {
......@@ -25,6 +25,7 @@ class Credentials {
throw new CredentialsClientSecretError("VK Client Secret not string or len =< 0", 0, ["client_secret" => $client_secret]);
}
$this->api_version = $api_version;
$this->api_service_key = $api_service_key;
}
/**
......@@ -47,5 +48,8 @@ class Credentials {
public function get_api_version() {
return $this->api_version;
}
public function get_service_key() {
return $this->$api_service_key;
}
}
?>
\ No newline at end of file
......@@ -2,6 +2,8 @@
namespace X\Social\VK;
use X\ETrace\System as ETSystem;
use X\Network\Http\Client as HttpClient;
use X\Social\VK\ServerToken as VKServerToken;
use VkConfig;
class VKAPICredentialsIsNull extends ETSystem {}
class VKAPIResponseError extends ETSystem {}
......@@ -35,6 +37,8 @@ class VKAPI {
if (is_null($this->Credentials)) {
throw new VKAPICredentialsIsNull("VK Credentials is NULL", 0);
}
}
/**
......@@ -46,7 +50,11 @@ class VKAPI {
if ( ! isset($params['v'])) {
$params["v"] = "5.28";
}
if ( ! isset($params['access_token'])) {
//$server_token = new VKServerToken($this->Credentials);
//$params["access_token"] = $server_token->get_token();
$params["access_token"] = $this->Credentials->get_service_key();
}
return $this->query($this->api_url . "method/" . $method, $params);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment