Commit d6591570 authored by Alex Ne's avatar Alex Ne

add vk api

parent d9a83f09
......@@ -48,7 +48,7 @@ class ClientResponse {
return $this->body;
}
public function get_json() {
public function json_decode() {
return json_decode($this->body, true);
}
}
......
......@@ -52,8 +52,8 @@ class ClientSettings {
$this->data["get"] = $out;
}
}
return $this;
}
return $this;
}
/**
......@@ -93,6 +93,7 @@ class ClientSettings {
if (isset($data["timeout"])) {
$this->data["timeout"] = intval($data["timeout"]) ?: 10;
}
return $this;
}
/**
......@@ -101,6 +102,7 @@ class ClientSettings {
*/
public function add_getvar($name, $value) {
$this->data["get"][$name] = $value;
return $this;
}
/**
......@@ -109,6 +111,7 @@ class ClientSettings {
*/
public function add_postvar($name, $value) {
$this->data["post"][$name] = $value;
return $this;
}
/**
......@@ -116,6 +119,7 @@ class ClientSettings {
*/
public function set_putvar($value) {
$this->data["put"] = $value;
return $this;
}
protected function build_url() {
......
......@@ -2,6 +2,24 @@
namespace X\Social;
class VK {
/**
* @var string
*/
protected $api_url = "";
}
?>
\ No newline at end of file
public function __construct() {}
/**
* @param string $method
* @param array $params
*/
public function api($method, $params = []) {
$Client = new X\Network\Http\Client($this->api_url . "/" . $method);
$Client->set_model_data(["post" => $params]);
if ($data = $Client->exec()->json_decode()) {
return $data;
}
return;
}
}?>
\ No newline at end of file
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