Code Monkey home page Code Monkey logo

line-bot-sdk-php's People

Contributors

be-hase avatar clarencetw avatar danielpclin avatar dependabot-preview[bot] avatar github-actions[bot] avatar hinoguma avatar itsuki-hayashi avatar k1rnt avatar kiwi-26 avatar moririnson avatar moznion avatar nanato12 avatar pangaunn avatar parsilver avatar renovate[bot] avatar satosby avatar shuheilocale avatar snmatsui avatar sor4chi avatar syleeeee avatar tamucola avatar tessayeh avatar tkgauri avatar tokuhirom avatar tw0517tw avatar typerej avatar vaduz avatar vocolboy avatar yang-33 avatar yo-shun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

line-bot-sdk-php's Issues

VideoMessageBuilder cant save and forward

i've just used VideoMessageBuilder for reply

$p2 = "https://url/1.mp4";
$p1 = "https://url/1.jpg";
$this->bot->replyMessage($replyToken, new VideoMessageBuilder($p2,$p1));

it success. i cant download the video and forward it. is there any information i missed about this feature?

Upgrade to Guzzle 6.2

The current version of Guzzle is 6.2 and it has numerous incompatible API changes. The problem with PHP composer is that you can only install one version of a package and by installing this one, it is not possible to install any package written against Guzzle 6.

ImageMessageBuilder show in Mobile, But Not in PC

if(preg_match('(\bflip card\b)', $text) != 0 || preg_match('(\bflip a card\b)', $text) != 0){
       $image = base_url("/asset/card/".$this->flip_card().".png");
       $card = new \LINE\LINEBot\MessageBuilder\ImageMessageBuilder(
		$image,
		$image
       );
      $bot->replyMessage($reply_token, $card);
}

In Phone i could see the images, But in LINE PC the images are not showed and they didn't stop loading

Pc site :
line_image

The image work find in mobile
line_image2

Is this the right place i share this problem here?

vendor/autoload.php

hello ... where can I find the file
require DIR . '/../vendor/autoload.php';

thanks for the help

Cann't get message type for non text message

I can not get the attribute message['type'] with method getMessageType() on the event object when a user sends a sticker or a non text message. And my server did not record any error. Is this a bug in the SDK or in the API?

グループチャット時のメッセージイベントについて

はじめまして。

グループチャット時は、
受け取ったメッセージイベントのソースに、ルーム情報が入りますが、
合わせて、ユーザー情報(IDなど)を知る方法はないでしょうか?

よろしくお願いします。

Validating channel access.

Hello and thanks for this great sdk. Please is it possible to check if a combination of Channel Secret and Channel Access Token are valid. Hope my question as well asked. That is, is there an endpoint which requirs say these 2 keys and returns a response wheater they are valid or not?

Regards.

Could send ImageMessage but not ImageMap

In the chat window it says "Unable to load photo." and a button try again
Here are my code snippet

$imagemapUriActionBuilder = new \LINE\LINEBot\ImagemapActionBuilder\ImagemapUriActionBuilder(
            'https://this.is.just.placeholder/',
            new \LINE\LINEBot\ImagemapActionBuilder\AreaBuilder(0,0,560,120)
        );
$imagemapMessageActionBuilder = new \LINE\LINEBot\ImagemapActionBuilder\ImagemapMessageActionBuilder(
            'Some Tag Line',
            new \LINE\LINEBot\ImagemapActionBuilder\AreaBuilder(0,120,560,120)
        );
$ImageMapMessageBuilder = new \LINE\LINEBot\MessageBuilder\ImagemapMessageBuilder(
    'https://this.image.is.working.on.imagemessagebuilder.but.not.here',
    'Text to be displayed',
    $baseSizeBuilder,
    [
        $imagemapUriActionBuilder,
        $imagemapMessageActionBuilder
    ]
);

$response = $bot->replyMessage($event->getReplyToken(), $ImageMapMessageBuilder);```

Did I miss something? 
The url is working just fine

How to find TargetMID ?

in /example/SendingSample/setting.php

return [
'channelId' => 'xxx', // I see
'channelSecret' => 'xxx', // I see
'channelMid' => 'xxx', // I see
'targetMid' => '???', // here I don't know, where I can found it?
];

Image not show properly in some domain

I tried push message with image, I noticed images from some domain display properly but some domain (with HTTPS) cannot display properly (show (i) icon instead), anyone know, what is the cause of this problem?

Webhook Configuration failed for Sub-Level Domain

Hi,
I am not sure this is right place to raise my issue regarding Webhook config. Currently integrating Line app using PHP. Under Message API, when configuring sub domain path in Webhook it throws an error such as "could not connect SSL" though domain is SSL certificate. But if give Top level domain it accepts and Line gives responses whenever user any activities on official account.
2017-05-09_220218
2017-05-09_220034

And also please suggest the right channel to communicate Line Tech team.

Could i get user information such as name using getUserId() ?

Hello, i have little problem on user information, I have found some LINE BOT tutorial how to get the user name, but i always found they using LINE_CHANNEL_MID.

Unfortunately i don't have LINE_CHANNEL_MID in my BOT basic information. I only have Channel ID, Channel Secret, And Channel Access token. I don't know why i don't have it.

But all is find, i can get the text from user, get the user_id, room_id or group_id and i could send reply message to the user.

 ` $bot = new \LINE\LINEBot(
        new \LINE\LINEBot\HTTPClient\CurlHTTPClient('channel_access_token'),
        ['channelSecret' => 'channel_secret']
    );
    $signature = $_SERVER["HTTP_".\LINE\LINEBot\Constant\HTTPHeader::LINE_SIGNATURE];
    $body = file_get_contents("php://input");
    $events = $bot->parseEventRequest($body, $signature);
    foreach ($events as $event) {
        if ($event instanceof \LINE\LINEBot\Event\MessageEvent\TextMessage) {
            $reply_token = $event->getReplyToken();
            $user_id = $event->getUserId();

            //i want trying to get the user information like the user name, so i could send the name as reply message
      
        } 
    }'

could i get the user information by the user_id?

thank you

is it possible to send both of data of postback and text?

I read the document (https://devdocs.line.me/ja/#template-message) about postback. This reads it can send both of data and text at the same time.

But, as I saw the class of PostbackTemplateActionBuilder, it can't send text.

class PostbackTemplateActionBuilder implements TemplateActionBuilder
{
    /** @var string */
    private $label;
    /** @var string */
    private $data;

    /**
     * PostbackAction constructor.
     *
     * @param string $label Label of action.
     * @param string $data Data of postback.
     */
    public function __construct($label, $data)
    {
        $this->label = $label;
        $this->data = $data;
    }

    /**
     * Builds postback action structure.
     *
     * @return array Built postback action structure.
     */
    public function buildTemplateAction()
    {
            return [
                'type' => ActionType::POSTBACK,
                'label' => $this->label,
                'data' => $this->data,
            ];       

    }
}

Problem with multiple emoji

When I sent just one emoji, I got this from the callback

{
  ...
  "content": {
    "toType": 1,
    "createdTime": 1461747374328,
    "from": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "location": null,
    "id": "4232655156792",
    "to": [
      "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
    ],
    "text": null,
    "contentMetadata": {
      "STKTXT": "[]",
      "STKVER": "2",
      "STKID": "47977",
      "STKPKGID": "2000000"
    },
    "deliveredTime": 0,
    "contentType": 8,
    "seq": null
  }
  ...
}

The result likes the result from sticker.

But when I sent multiple emoji, I got this

{
  "content": {
    "toType": 1,
    "createdTime": 1461747388268,
    "from": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "location": null,
    "id": "4232656103122",
    "to": [
      "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"
    ],
    **"text": "(hahaha)(please!)(shocked)",**
    "contentMetadata": {
      "EMTVER": "4"
    },
    "deliveredTime": 0,
    "contentType": 1,
    "seq": null
  }
}

This result came with the text content type.

Is this by design or it will be updated?

Thank you

page not found

i have installed echobot, but i'm get notice page not found.

Determining extension of message content

When retrieving the content of a message (e.g. an image) it can not be determined, using the SDK, whether the image (or any other content) is of a given mime type (e.g. image/jpeg, image/png). This makes it hard to actually write the file to disk with the right extension.

Here's some example code that shows the issue:

// $message is an instance of ImageMessage

$line = new LINEBot(new CurlHTTPClient('<token>'), [
    'channelSecret' => '<secret>'
]);

$response = $line->getMessageContent($message->getMessageId());
if ($response->isSucceeded()) {
    // I can get the binary body with $response->getRawBody()
    // but I can't get the mime type, nor the extension.
    $filePath = tmpfile() . '<extension?>';
    file_put_contents($filePath, $response->getRawBody());
}

There's various solutions to the issue:

  • I can create my own HTTPClient with a getMimeType() method, but since it's a private member of the LINEBot class, I can't access this in the code.
  • In addition to the above I can overwrite the Response class, but that just seems to much overwriting already.
  • Do the above, but in this repository
  • Get the extension and/or from the ImageMessage class (if sent back from the API)

In the KitchenSink example all images are written as .jpeg so it could be that all images are actually JPEG's, but that is not documented.

Could someone provide some guidance to the above? I can make a pull request based on suggestion and/or feedback, but looking to see what the right way to go is.

Not define for '$response->isSecceeded()'

From example code :
$textMessageBuilder = new \LINE\LINEBot\MessageBuilder\TextMessageBuilder('hello');
$response = $bot->replyMessage('<reply token>', $textMessageBuilder);
if ($response->isSecceeded()) {
echo 'Succeeded!';
return;
}

I want to execute example code. But php console show the error message for me.
Please check this function name exist or not.

Thank you.

PostbackTemplateActionBuilder in wrong key

PostbackTemplateActionBuilder.php

public function buildTemplateAction(){
return [
'type' => ActionType::POSTBACK,
'label' => $this->label,
'data.json' => $this->data
];
}

will work if replace data.json with data

PostbackEvent.php

public function getPostbackData(){
return $this->event['postback']['data.json'];
}

will work if replace data.json with data

is that possible to update session data everytime callbacked or everytime bot has replyed message?

Hello, im using codeigniter to use BOT, and i want trying to use session as key for reply message. So everytime my bot has reply a message the last session should be updated.

I do this because, im trying to prevent to reply same text with same keyword

heri is my code :

    $bot = new \LINE\LINEBot(
        new \LINE\LINEBot\HTTPClient\CurlHTTPClient($reply_token),
        ['channelSecret' => $secret]
    );
    if(isset( $_SESSION['count']){
        $count = $_SESSION['count'];
    }else{
        $count = 0
    }

    $signature = $_SERVER["HTTP_".\LINE\LINEBot\Constant\HTTPHeader::LINE_SIGNATURE];
    $body = file_get_contents("php://input");

    $events = $bot->parseEventRequest($body, $signature);
    foreach ($events as $event) {
        if ($event instanceof \LINE\LINEBot\Event\MessageEvent\TextMessage) {
            $reply_token = $event->getReplyToken();

            $text = strtolower($event->getText());
            if($text == 'hi'){
                $reply_message = $items[array_rand($items)];
                $bot->replyText($reply_token, $reply_message);
            }else if ($text == 'makanya belajar'){
                $reply_message = $teach[array_rand($teach)];
                $bot->replyText($reply_token, $reply_message);
            }else if($text == 'vin' || $text == 'zi' || 'vinzi'){
                if($count != 6){
                    $_SESSION['count'] += 1;
                    $reply_message = $name[$count];
                    $bot->replyText($reply_token, $reply_message);

                }else{
                    $reply_message = $name[$count];
                    unset($_SESSION['count']);
                    $bot->replyText($reply_token, $reply_message);
                }
            }
        }
    }

before i tried to use it, i try to var_dump all the session and refresh my callback funtion, i could get the result what i want. but after i tried chat my bot, he always send the same text. thak you

Multiplemessage disregard content after Imagemap

Hi,

I am able to send a MultiMessage with a text followed by an Imagemap.
But, when I try to send an Imagemap and followed by a text. I got only the Imagemap and the text never showed up.

Did I missed something?

How to switch BOT to new API

I am trying to upgrade my BOT to the 1.0 SDK. The problem is that I receive calls in the old format. There is a "HTTP_X_LINE_CHANNELSIGNATURE" header only and the body JSON is the old format.

How do I switch my channel to use the new SDK? I can configure it at https://developers.line.me but don't see anything. I could not find any documentation about that either.

leaveRoom() and leaveGroup() didn't work

got 411 bad request from server.
add request body can fix the problem.

LINEBot.php:137
return $this->httpClient->post($this->endpointBase . '/v2/bot/group/' . urlencode($groupId) . '/leave', ["dummy"=>"dummy"]);

LINEBot.php:148
return $this->httpClient->post($this->endpointBase . '/v2/bot/room/' . urlencode($roomId) . '/leave', ["dummy"=>"dummy"]);

[Input] Set default value for parameter

Dear Admin,

I have a suggestion to set default value for parameter on TextMessageBuilder

class TextMessageBuilder implements MessageBuilder { ... public function __construct($text, array $extraTexts = array()) ... }

i think $extraTexts is an optional parameter, and it made error when someone forget to set value for it.

Get user ID from group chat message

When receiving a message from a room, only the room ID is given as the source of the message. How do I look up the user ID of the sender?

auto reply not work

i just installed kitchen sink on hosting and have configured webhook to callback. when i try to chat from phone 'profile', line bot cant reply. i just want to learn event handler especially text message

Can't Send Carousel

$imageUrl = "http://1.bp.blogspot.com/-9izs08OyhuU/VeaBPrheKHI/AAAAAAAACMQ/uUN7ELsMw_o/s1600/Gambar-Konyol-Lucu-Gila-Unik-Aneh-34.jpg";
$carouselTemplateBuilder = new CarouselTemplateBuilder([
  new CarouselColumnTemplateBuilder('foo', 'bar', $imageUrl, [
    new UriTemplateActionBuilder('Go to line.me', 'https://line.me'),
    new PostbackTemplateActionBuilder('Buy', 'action=buy&itemid=123'),
  ]),
  new CarouselColumnTemplateBuilder('buz', 'qux', $imageUrl, [
     new PostbackTemplateActionBuilder('Add to cart', 'action=add&itemid=123'),
     new MessageTemplateActionBuilder('Say message', 'hello hello'),
  ]),
]);

file_put_contents('php://stderr', 'MessageBuilder: '.json_encode($carouselTemplateBuilder));
$messageBuilder = new TemplateMessageBuilder('Button alt text', $carouselTemplateBuilder);

$this->bot->pushMessage($wong, $messageBuilder);

This is part of my code... I want send a Carousel but the bot isn't reply.

$response has no 'getBody' method when push message

There is a slight error in API Reference ( [https://devdocs.line.me/en/?php#reply-message]("Push Message" section) ):

$httpClient = new \LINE\LINEBot\HTTPClient\CurlHTTPClient('<channel access token>');
$bot = new \LINE\LINEBot($httpClient, ['channelSecret' => '<channel secret>']);

$textMessageBuilder = new \LINE\LINEBot\MessageBuilder\TextMessageBuilder('hello');
$response = $bot->pushMessage('<to>', $textMessageBuilder);

echo $response->getHTTPStatus() . ' ' . $response->getBody();

After I tried this code, i got error message say $response has no 'getBody' method,
I think we should call 'getRawBody' method, not 'getBody'.

Images not shown properly in chat window

Image message sent successfully (200 OK) but image is not displayed properly in chat window

203.104.146.152 - - [20/Nov/2016:13:28:16 +0700] "POST /callback/line/official HTTP/1.1" 200 12 "-" "LineBotWebhook/1.0"
203.104.146.152 - - [20/Nov/2016:13:28:21 +0700] "POST /callback/line/official HTTP/1.1" 200 12 "-" "LineBotWebhook/1.0"
203.104.146.152 - - [20/Nov/2016:13:28:24 +0700] "POST /callback/line/official HTTP/1.1" 200 12 "-" "LineBotWebhook/1.0"
203.104.146.152 - - [20/Nov/2016:13:31:39 +0700] "POST /callback/line/official HTTP/1.1" 200 12 "-" "LineBotWebhook/1.0"
203.104.146.152 - - [20/Nov/2016:13:34:57 +0700] "POST /callback/line/official HTTP/1.1" 200 12 "-" "LineBotWebhook/1.0"

screen shot 2016-11-20 at 13 44 40

  • Image URL is correct and can be opened from browser
    https://line.yefta.com/images/baka.jpg
  • SSL cert is not the ones from Let's encrypt nor Cloudflare
  • Images can be displayed properly if running the code using local php (php -S) and ngrok

screen shot 2016-11-20 at 13 47 12

Get Coupon Event

can we get user id or something data about coupon feature in LINE?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.