появлялось окно с переводом 1 голоса. + в базу перешло значение поля comment, при удачной операции.
Это iFrame приложение
Я делаю так
index.php
Код: Выделить всё
<html><head> <script src="http://vk.com/js/api/xd_connection.js" type="text/javascript"></script> <link rel='stylesheet' type='text/css' href='css/main.css' /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type='text/javascript' src='js/jquery.min.js'></script> <script type="text/javascript" charset="utf8" > window.onload = (function() { VK.init(function() { // узнаём flashVars, переданные приложению GET запросом. Сохраняем их в переменную flashVars var parts=document.location.search.substr(1).split("&"); var flashVars={}, curr; for (i=0; i<parts.length; i++) { curr = parts[i].split('='); flashVars[curr[0]] = curr[1]; } var viewer_id = flashVars['viewer_id']; $('#uid').attr('value',viewer_id); // получаем профиль VK.api("users.get", {uids:viewer_id}, function(data) { document.getElementById('info').innerHTML = '<b>' + data.response[0].first_name + ' ' + data.response[0].last_name + '</b>'; }); }); }); $('#link_btn').click(function() { VK.callMethod("showOrderBox",{type: 'item', item: 'add_link'}); }); </script></head><body> <div id='info'></div><form id='link' name='link' action=''> <input value='ваш комментарий' type='text' name='comment'> <a href='#' id='link_btn'>Купить</a></form> </body></html>
Код: Выделить всё
<?phpheader("Content-Type: application/json; encoding=utf-8"); $secret_key = '1111111111111'; // Защищенный ключ приложения $input = $_POST; // Проверка подписи $sig = $input['sig']; unset($input['sig']); ksort($input); $str = ''; foreach ($input as $k => $v) { $str .= $k.'='.$v; } if ($sig != md5($str.$secret_key)) { $response['error'] = array( 'error_code' => 10, 'error_msg' => 'Несовпадение вычисленной и переданной подписи запроса.', 'critical' => true ); } else { // Подпись правильная switch ($input['notification_type']) { case 'get_item_test': // Получение информации о товаре в тестовом режиме $item = $input['item']; if ($item == 'item1') { $response['response'] = array( 'item_id' => 125, 'title' => '300 золотых монет (тестовый режим)', 'photo_url' => 'http://somesite/images/coin.jpg', 'price' => 5 ); } elseif ($item == 'item2') { $response['response'] = array( 'item_id' => 127, 'title' => '500 золотых монет (тестовый режим)', 'photo_url' => 'http://somesite/images/coin.jpg', 'price' => 10 ); } else { $response['error'] = array( 'error_code' => 20, 'error_msg' => 'Товара не существует.', 'critical' => true ); } break; case 'order_status_change_test': // Изменение статуса заказа в тестовом режиме if ($input['status'] == 'chargeable') { $order_id = intval($input['order_id']); $app_order_id = 1; // Тут фактического заказа может не быть - тестовый режим. $response['response'] = array( 'order_id' => $order_id, 'app_order_id' => $app_order_id, ); } else { $response['error'] = array( 'error_code' => 100, 'error_msg' => 'Передано непонятно что вместо chargeable.', 'critical' => true ); } break; } } echo json_encode($response); ?>