public function sendMessage($sendID,$message){
if ($sendID != 0 and $sendID != '0') {
return $this->request('messages.send',array('message'=>$message, 'peer_id'=>$sendID));
} else {
return true;
}
}
public function request($method,$params=array()){
$url = 'https://api.vk.com/method/'.$method;
$params['access_token']=$this->token;
$params['v']=$this->v;
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type:multipart/form-data"
));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$result = json_decode(curl_exec($ch), True);
curl_close($ch);
} else {
$result = json_decode(file_get_contents($url, true, stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query($params)
)
))), true);
}
if (isset($result['response']))
return $result['response'];
else
return $result;
}