Skip to content

Commit bccf13d

Browse files
committed
Update
1 parent 2fd8455 commit bccf13d

File tree

1 file changed

+84
-5
lines changed

1 file changed

+84
-5
lines changed

api.php

Lines changed: 84 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,27 +449,38 @@ public function Location($title, $address, $latitude, $longitude) {
449449
}
450450

451451
public function Imagemap($baseUrl, $altText, $width, $height, $action) {
452+
if (isset($action["type"])){
453+
$actions = array($action);
454+
}else{
455+
$actions = $action;
456+
}
457+
if ($width == 0 and $height == 0){
458+
list($width, $height) = getimagesize($baseUrl);
459+
}
460+
$baseSize = array(
461+
"width" => $width,
462+
"height" => $height,
463+
);
452464
$MsgObject = array(
453465
"type" => "imagemap",
454466
"baseUrl" => $baseUrl,
455467
"altText" => $altText,
456-
"baseSize.width" => $width,
457-
"baseSize.height " => $height,
458-
"actions" => $action
468+
"baseSize" => $baseSize,
469+
"actions" => $actions
459470
);
460471
return $MsgObject;
461472
}
462473

463474
public function Template($altText, $template) {
464475
$MsgObject = array(
465476
"type" => "template",
466-
"altText" => $url,
477+
"altText" => $altText,
467478
"template" => $template
468479
);
469480
return $MsgObject;
470481
}
471482

472-
public function Flex($url, $contents = null) {
483+
public function Flex($altText, $contents) {
473484
$MsgObject = array(
474485
"type" => "flex",
475486
"altText" => $altText,
@@ -480,11 +491,79 @@ public function Flex($url, $contents = null) {
480491
}
481492

482493
class LINEMSG_Imagemap {
494+
public function action($type, $url_or_text, $area, $label = null) {
495+
if($type == "link"){
496+
$dataType = "linkUri";
497+
}elseif($type == "message"){
498+
$dataType = "text";
499+
}else{
500+
return null;
501+
}
502+
$object = array(
503+
"type" => $type,
504+
"label" => $label,
505+
$dataType => $url_or_text,
506+
"area" => $area
507+
);
508+
return $object;
509+
}
483510

511+
public function actionArea($x, $y, $width, $height){
512+
$object = array(
513+
"x" => $x,
514+
"y" => $y,
515+
"width" => $width,
516+
"height" => $height
517+
);
518+
return $object;
519+
}
484520
}
485521

486522
class LINEMSG_Template {
523+
public function __construct($template){
524+
switch($template){
525+
case "buttons":
526+
$this->object = array(
527+
"type" => "buttons",
528+
"thumbnailImageUrl" => null,
529+
"imageAspectRatio" => null,
530+
"imageSize" => null,
531+
"imageBackgroundColor" => null,
532+
"title" => null,
533+
"text" => null,
534+
"defaultAction" => null,
535+
"actions" => null
536+
);
537+
break;
538+
case "confirm":
539+
$this->object = array(
540+
"type" => "confirm",
541+
"text" => null,
542+
"actions" => null
543+
);
544+
break;
545+
case "carousel":
546+
$this->object = array(
547+
"type" => "carousel",
548+
"columns" => null,
549+
"imageAspectRatio" => null,
550+
"imageSize" => null,
551+
);
552+
break;
553+
case "image_carousel":
554+
$this->object = array(
555+
"type" => "image_carousel",
556+
"columns" => null,
557+
);
558+
break;
559+
default:
560+
return null;
561+
}
562+
}
487563

564+
public function out(){
565+
return $this->object;
566+
}
488567
}
489568

490569
class LINEMSG_FlexContainer {

0 commit comments

Comments
 (0)