PHP code example of avplab / viber-api
1. Go to this page and download the library: Download avplab/viber-api library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
avplab / viber-api example snippets
#Controller/IndexController.php
namespace EchoBot\Controller;
use AvpLab\ViberApi\Framework\Controller;
use AvpLab\ViberApi\Message\TextMessage;
class IndexController extends Controller
{
public function conversationStartedAction()
{
if ($this->getRequest()->getData()->subscribed) {
return new TextMessage('Welcome back !');
} else {
return new TextMessage('Welcome ! I will respond with the same message');
}
}
public function indexAction()
{
$message = new TextMessage($this->getRequest()->getMessageText());
$this->reply($message);
}
}