CODE
Код: Выделить всё
<?php
require('VkApi.class.php');//// в нем и находиться функция ниже напишу
$app_id = '186042432'; // id приложения
$api_secret = 'qkNBjgcdpLeW'; // Защищенный ключ с вкладки "Платежи"
$auth_key = $_POST['auth_key']; // auth_key из FlashVars приложения
$viewer_id = $_POST['viewer_id']; // id просматривающего приложение
$uid = $viewer_id;
function get_url($query) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $query);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
return curl_exec($ch);
curl_close($ch);
}
if ($user_balance->balance >=200)
{ // если на счету пользователя не меньше 1 голоса
// Списываем со счета пользователя голос
$votes = 100; // количество голосов (1 голос = 100)
$query = $api->withdrawVotes($uid, $votes);
get_url($query);// эта функция тожк находиться в VkApi.class.php и этот код полностью работает
/// но когда я делаю так
$message_win = 'Здравствуйте Вы стали победителем этого месяца,пожалуйста обратитесь к Администратору приложения. Мы вас поздравляем вы выиграли '.$prizname.' или '.$prizvotes.'';
$query = $api->sendNotification($uid, $message_win);
get_url($query);
//отпровляем уведомление победителю
//получается ошибка:Fatal error call to a member function sendNotification() on a non-object
?>
CODE
Код: Выделить всё
public function sendNotification ($uid, $message_win)
{
$api = new VkApi($this->api_id,
'secure.sendNotification',
$this->secret,
$this->format,
$this->version,
$this->server_url,
$this->timestamp,
$this->random);
$api->addParameter('uids', join(',', $uid));
$api->addParameter('message', $message_win);
return $api->getQuery();
}