Telegram - ?

IP Asterisk? . VK () . .


access_token

, Developers VK. ( ) :

   API VK
  • - . , Asterisk;
  • - Standalone-;

. ID , :

 ID  VK API

. :

https://oauth.vk.com/authorize?client_id=1234567&scope= offline,messages&redirect_uri=https://oauth.vk.com/blank.html&display=page&v=5.37&response_type=token

client_id , (ID ). VK API :

 access_token VK API

, VK :

 access_token
{"error":"invalid_request","error_description":"Security Error"}, VK

Asterisk.


Asterisk

.php. asteriskvk.php :

#!/usr/bin/php -q
<?php
require('phpagi.php'); 
$agi = new AGI(); 
$message = "    : ";
$message .= $agi->request['agi_callerid'];
$id = "ID  ";
$token = "";
function send($id , $message, $token)
{
    $url = 'https://api.vk.com/method/messages.send';
    $params = array(
        'user_id' => $id,
        'message' => $message,
        'access_token' => $token,
        'v' => '5.37',
    );
     $result = file_get_contents($url, false, stream_context_create(array(
        'http' => array(
            'method'  => 'POST',
            'header'  => 'Content-type: application/x-www-form-urlencoded',
            'content' => http_build_query($params)
        )
    )));
}
send($id, $message, $token);
?>

:

  • $id - , . user_id, ID ;
  • $token - API - , ;

/var/lib/asterisk/agi-bin/ :

chmod 755 /var/lib/asterisk/agi-bin/asteriskvk.php 
chown asterisk:asterisk /var/lib/asterisk/agi-bin/asteriskvk.php 
dos2unix /var/lib/asterisk/agi-bin/asteriskvk.php

:

exten => _.,n,AGI(asteriskvk.php)

:

 Asterisk  VK  API

?

 .

P.S. , :)

"",