1. настораживает - это 'v' => '5.0'.
рабочий на 100%.
private $token = 'хххххххххххххххххххххххххххххххххххххххххххххххх';
private $_ok = 'OK';
public function messages_send ($paramm = []){
if (!$paramm) {return false;}
else {
$url = trim('https://api.vk.com/method/messages.send?'.http_build_query($paramm));
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$data = curl_exec($curl);
curl_close($curl);
// curl_setopt($curl, CURLOPT_ENCODING ,"");
$_id_message = json_decode($data)->response;
if (isset ($_id_message)) {
if (is_int($_id_message)){
return $this->_ok;
}
} else {
return $data;
}
}
}
Использовать :
case 'group_leave':
$request_params = array (
'message' => 'Ливнул',
'user_id' =>$callback_object->object->user_id,
'access_token' => $this->token,
'read_state' => 1,
);
return $this-> messages_send ($request_params);
break;
case 'group_join':
$request_params = array (
'message' => 'Добро пожаловать!',
'user_id' =>$callback_object->object->user_id,
'access_token' => $this->token,
'read_state' => 1,
);
return $this-> messages_send ($request_params);
break;