LINE-Bot-API

 view release on metacpan or  search on metacpan

eg/push_imagemap-template.pl  view on Meta::CPAN

use strict;
use warnings;
use lib 'lib';

use LINE::Bot::API;

use LINE::Bot::API;
use LINE::Bot::API::Builder::SendMessage;
use LINE::Bot::API::Builder::ImagemapMessage;
use LINE::Bot::API::Builder::TemplateMessage;

my $channel_secret         = $ENV{CHANNEL_SECRET};
my $channel_access_token   = $ENV{CHANNEL_ACCESS_TOKEN};
my $messaging_api_endpoint = $ENV{MESSAGING_API_ENDPOINT};

my $imagemap_image_url = $ENV{IMAGEMAP_IMAGE_URL};
my $template_image_url = $ENV{TEMPLATE_IMAGE_URL};

my($to_id, $text) = @ARGV;

my $bot = LINE::Bot::API->new(
    channel_secret         => $channel_secret,
    channel_access_token   => $channel_access_token,
    messaging_api_endpoint => $messaging_api_endpoint,
);

my $messages = LINE::Bot::API::Builder::SendMessage->new->add_text( text => $text );

# Imagemap Message
my $imagemap = LINE::Bot::API::Builder::ImagemapMessage->new(
    base_url    => $imagemap_image_url,
    alt_text    => 'altText',
    base_width  => 1040,
    base_height => 1040,
)->add_uri_action(
    uri         => 'http://example.com/',
    area_x      => 0,
    area_y      => 0,
    area_width  => 1040,
    area_height => 520,
)->add_message_action(
    text        => 'message',
    area_x      => 0,
    area_y      => 520,
    area_width  => 1040,
    area_height => 520,
);
$messages->add_imagemap($imagemap->build);


# Template Message
my $buttons = LINE::Bot::API::Builder::TemplateMessage->new_buttons(
    alt_text  => 'altText',
    image_url => $template_image_url,
    title     => 'buttons',
    text      => 'description',
)->add_postback_action(
    label => 'postback',
    data  => 'postback data',
    text  => 'postback message',
)->add_message_action(
    label => 'message',
    text  => 'message',
)->add_uri_action(
    label => 'uri',
    uri   => 'http://example.com/',
)->add_message_action(
    label => 'message2',
    text  => 'message2',
);
$messages->add_template($buttons->build);

my $confirm = LINE::Bot::API::Builder::TemplateMessage->new_confirm(
    alt_text => 'altText',
    text     => 'confirm',
)->add_postback_action(
    label => 'postback',
    data  => 'postback data',
    text  => 'postback message',
)->add_message_action(
    label => 'message',
    text  => 'message',
)->add_uri_action(
    label => 'uri',



( run in 0.650 second using v1.01-cache-2.11-cpan-524268b4103 )