SDK Php Chatfue Socola
Using php to generate JSON for Chatfuel bot
use Socola\Chatfuel;
$bot = new Chatfuel();
$text = 'Socola';
$texts = [$text, $text, $text, $text];
$bot->sendText($text);
$bot->sendText($texts);
$image = 'http://i.imgur.com/luWlRwV.jpg';
$images = [
'http://i.imgur.com/luWlRwV.jpg',
'http://i.imgur.com/luWlRwV.jpg'
];
$bot->sendImage($image);
$bot->sendImage(images);
$file = 'https://01b02091.ngrok.io/test.pdf';
$files = array(
'https://01b02091.ngrok.io/test.pdf',
'https://01b02091.ngrok.io/test.pdf'
);
$bot->sendFile($file);
$bot->sendFile($files);
$audio = 'https://01b02091.ngrok.io/test.mp3';
$audios = [
'https://01b02091.ngrok.io/test.mp3',
'https://01b02091.ngrok.io/test.mp3'
];
$bot->sendAudio($audio);
$bot->sendAudio($audios);
$title = "button to url";
$url = "http://www.facebook.com";
$buttonToURL = $bot->createButtonToURL($title, $url, $setAttributes = Null);
$title = "button to block";
$block = "re-start";
$buttonToBlock = $bot->createButtonToBlock($title, $block, $setAttributes = Null);
$buttonShare = $bot->createButtonShare();
$phoneNumber = '096******5';
$buttonCall = $bot->createButtonCall($phoneNumber, $title = 'Call');
$block = 're-start';
$blocks = [
'play',
'pause'
];
$bot->createButtonQuickReply($title, $block);
$bot->createButtonQuickReply($title, $blocks);
$text = 'this is text card';
$uttons = [
$buttonToURL,
$buttonToBlock,
$buttonShare
];
$bot->sendTextCard($text, $button);
$bot->sendTextCard($text, $buttons);
$title = 'this is element';
$image = 'http://i.imgur.com/luWlRwV.jpg';
$subTitle = 'this is sub title';
$element = $bot->createElement($title, $image, $subTitle, $button_or_arrayButtons);
$arrayElements = array(
$element1,
$element2
);
$bot->sendGallery($element_or_arrayElements);
You can switch type “top_element_style” between “large” and “compact”.
$topElementStyle = 'large';
$bot->sendList($arrayElements, $topElementStyle);