<?php // http://vk.com/dev/wall.delete ini_set('display_errors', true); include '../vk.api.php'; include 'print_var.php'; include 'lime.php'; include 'config.php'; $v = new Vk($config); // test case $t = new lime_test(1); $response = $v->api('wall.delete', array('post_id' => 0)); print_var($response); $t->isa_ok($response[0], 'integer', 'return 1 for success');
protected function _execute(array $params) { $vk = Vk::instance(); $user_ids = array(); $message = 'У вашего объявления обновился статус!'; $result = NULL; try { $user_ids = Utils::getNotifyUserIDs(); } catch (Database_Exception $e) { Minion_CLI::write($e->getMessage()); return; } if (count($user_ids) == 0) { Minion_CLI::write('no users'); return; } try { $vk->login(); $result = $vk->api('secure.sendNotification', array('user_ids' => implode($user_ids, ','), 'message' => urlencode($message), 'client_secret' => $vk->config['VK_APP_SECRET'])); } catch (Kohana_Exception $e) { Minion_CLI::write($e->getMessage()); return; } if (is_null($result)) { Minion_CLI::write('wtf?'); return; } try { Utils::uncheckUsersNotifyByIDs($user_ids); } catch (Database_Exception $e) { Minion_CLI::write($e->getMessage()); return; } Minion_CLI::write('done!'); }
/** * Singelton pattern * * @return Vk */ public static function instance() { if (!isset(Vk::$_instance)) { $config = Kohana::$config->load('vk'); Vk::$_instance = new Vk($config); } return Vk::$_instance; }
protected function _dispatch($method, $params = null, $source = null) { $content = $params[0]; return parent::_dispatch($method, $params, $source); $auth = $content->auth; ServerConfig::setLang($content->lang); if ($content->platform_id != null) { $platform_id = $content->platform_id; } else { if ($content->user_id != null) { $user_id = $content->user_id; $platform_id = AutoIncIdGenerator::getPlatformId($user_id); } } $vk = new Vk($platform_id); if ($vk->auth($auth)) { return parent::_dispatch($method, $params, $source); } Logger::error('Method "' . $method . '" auth failed' . " sk={$session_key} platform_id={$platform_id} "); return array('status' => 'error', 'msg' => 'auth failed'); }
public static function synchronizeStatuses() { $tasks = Vk::getTasks(); $tasks = ArrayHelper::merge($tasks, Instagram::getTasks()); $tasks = ArrayHelper::merge($tasks, Twitter::getTasks()); $tasks = ArrayHelper::merge($tasks, AskFM::getTasks()); foreach ($tasks as $task) { if ($task->finished) { $order = Order::findOne(['foreign_id' => $task->id]); if (isset($order->status)) { if ($order->status == Order::PROCESSED) { $order->status = Order::DONE; $order->save(); } } } } }
<?php // http://vk.com/dev/wall.post ini_set('display_errors', true); include '../vk.api.php'; include 'print_var.php'; include 'lime.php'; include 'config.php'; $v = new Vk($config); // test case $t = new lime_test(2); $response = $v->api('wall.post', array('message' => 'I testing API form https://github.com/fdcore/vk.api')); print_var($response); $t->isa_ok($response, 'array', 'json array response'); $t->isa_ok($response['post_id'], 'integer', 'return post_id');
<?php $token = 'eb4e624a5c085aa05415d17ce36c92b495ed358641c5369ff9f18d1c45194b32cdb1230b426497dee65e3'; $group_id = '135155223'; $user_id = '400611812'; $vk = new Vk($token); //получаем ссылку для файла $upload_server = $vk->docsGetWallUploadServer($token); echo '<pre>'; var_dump($upload_server); echo '</pre>'; $path = dirname(__FILE__) . "/143.pdf"; //$upload = $vk->upload_doc($upload_server['upload_url'], $path); $upload_url = $upload_server['upload_url']; $ch = curl_init($upload_url); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data")); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); curl_setopt($ch, CURLOPT_POSTFIELDS, $path); $upload_data = json_decode(curl_exec($ch), true); var_dump($upload_data); //$response = $this->request('docs.save', $upload_data); //var_dump($upload); /*$save = $vk->photosSaveWallPhoto([ 'group_id' => $group_id, 'photo' => $upload['photo'], 'server' => $upload['server'], 'hash' => $upload['hash'] ] );*/
<?php ini_set('display_errors', true); include '../vk.api.php'; include 'print_var.php'; include 'lime.php'; include 'config.php'; $v = new Vk($config); $links = array(); $links['code'] = $v->get_code_token('code'); $links['token'] = $v->get_code_token('token'); if (is_array($links) && count($links) > 0) { foreach ($links as $l) { echo printf('<p><a href="%s" target="_blank">%s</a></p>', $l, $l); } } print_var($links); // test case $t = new lime_test(2); $t->isa_ok($links['code'], 'string', 'get_code_token(\'code\') returns a string'); $t->isa_ok($links['token'], 'string', 'get_code_token(\'token\') returns a string');
<?php // http://vk.com/dev/upload_files?f=%D0%97%D0%B0%D0%B3%D1%80%D1%83%D0%B7%D0%BA%D0%B0%20%D0%B4%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D0%BE%D0%B2 ini_set('display_errors', true); include '../vk.api.php'; include 'print_var.php'; include 'lime.php'; include 'config.php'; // нужны права docs $v = new Vk($config); // test case $t = new lime_test(2); // получаем имя аттача (string) $attach_doc_file = $v->upload_doc(0, 'iZKE4JdP4Q0mT.jpg'); print_var($attach_doc_file); if ($attach_doc_file) { $response = $v->api('wall.post', array('message' => 'тестирую api документов', 'attachments' => $attach_doc_file)); print_var($response); } else { $response = false; } $t->isa_ok($response, 'array', 'json array response'); $t->isa_ok($response['post_id'], 'integer', 'return post_id');
<?php ini_set('display_errors', true); include '../vk.api.php'; include 'print_var.php'; include 'lime.php'; include 'config.php'; $v = new Vk($config); $response = $v->get_token('c413608d4f8a0ffc7b'); print_var($response);
<?php // http://vk.com/dev/wall.post ini_set('display_errors', true); include '../vk.api.php'; include 'print_var.php'; include 'lime.php'; include 'config.php'; $v = new Vk($config); // test case $t = new lime_test(2); $attach_video = $v->upload_video(array('link' => 'http://www.youtube.com/watch?v=5ZeA4AMrcd8', 'title' => 'Tasogare Otome X Amnesia / OST (Nika Lenina Russian Version)', 'description' => "Трек оригинал: Hiiragi Nao - Requiem\nАранжировка: Аlex Makshanov\nПеревод: Evafan\nРабота со звуком: AnsverITO\nВокал: Nika Lenina\nВидео: Sadzurami", 'wallpost' => 1)); $response = $v->api('wall.post', array('message' => 'тестирую api', 'attachments' => $attach_video)); print_var($response); $t->isa_ok($response, 'array', 'json array response'); $t->isa_ok($response['post_id'], 'integer', 'return post_id');