diff --git a/composer.json b/composer.json index f1bdde7..acb7ba2 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "getjump/vk", + "name": "den67rus/vk", "description": "Library for work with API Vk.com", "keywords": ["php", "vk", "api", "library", "vkontakte"], "license": "MIT", @@ -10,7 +10,7 @@ } ], "require": { - "guzzlehttp/guzzle": "4.*", + "guzzlehttp/guzzle": "6.*", "php": ">=5.4.0" }, "require-dev": { diff --git a/src/getjump/Vk/RequestTransaction.php b/src/getjump/Vk/RequestTransaction.php index ee0090b..7244f09 100644 --- a/src/getjump/Vk/RequestTransaction.php +++ b/src/getjump/Vk/RequestTransaction.php @@ -157,8 +157,8 @@ public function fetchData() $args['sig'] = md5('/method/'.$this->methodName.'?'.http_build_query($args).$this->noHttpsSecret); } - $data = $this->guzzle->post(self::URL_VK_API.$this->methodName, ['body' => $args])->json(['object' => true]); - $c = new Api($data, $this->callback); + $data = $this->guzzle->post(self::URL_VK_API.$this->methodName, ['form_params' => $args])->getBody()->getContents(); + $c = new Api(json_decode($data), $this->callback); return $c; } diff --git a/src/getjump/Vk/Response/Response.php b/src/getjump/Vk/Response/Response.php index 6f6cf83..87dbe29 100644 --- a/src/getjump/Vk/Response/Response.php +++ b/src/getjump/Vk/Response/Response.php @@ -38,6 +38,10 @@ class Response implements \ArrayAccess, \Countable, \Iterator */ public function __construct($data, $callback = false) { + if(is_string($data)) { + return $this->data = $data; + } + foreach ($data as $key => $value) { if (property_exists($this, $key)) { continue; @@ -56,7 +60,11 @@ public function __construct($data, $callback = false) } $this->count = !isset($data->count) ? false : $data->count; if (is_array($data) || !isset($data->items)) { - $this->count = count($data); + if(is_array($data)) { + $this->count = count($data); + } else { + $this->count = 0; + } if (is_array($data) && is_callable($callback)) { foreach ($data as $d) { $this->data[] = call_user_func_array($callback, [$d]);