line-bot-sdk-csharp 2.2.2

dotnet add package line-bot-sdk-csharp --version 2.2.2
NuGet\Install-Package line-bot-sdk-csharp -Version 2.2.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="line-bot-sdk-csharp" Version="2.2.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add line-bot-sdk-csharp --version 2.2.2
#r "nuget: line-bot-sdk-csharp, 2.2.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install line-bot-sdk-csharp as a Cake Addin
#addin nuget:?package=line-bot-sdk-csharp&version=2.2.2

// Install line-bot-sdk-csharp as a Cake Tool
#tool nuget:?package=line-bot-sdk-csharp&version=2.2.2

LINE Messaging API SDK for C#

LINE Messaging API SDK for C#

NuGet NuGet

Installation

Using nuget

PM> Install-Package line-bot-sdk-csharp
> dotnet add package line-bot-sdk-csharp

Documentation

See the official API documentation for more information

How to use

Client

使用するにはまずクライアントを作成します。

var LineMessagingClient = new LineMessagingClient("channelAccessToken");

メッセージ送信

複数のメッセージを送信する必要がある場合は後述の 複数メッセージを送信する場合 を参照してください。

テキストメッセージ

ReplyTextAsync もしくは PushTextAsync を使用します。

await LineMessagingClient.ReplyTextAsync("replyToken", "HelloWorld");
await LineMessagingClient.PushTextAsync("to", "HelloWorld");

スタンプメッセージ

ReplyStickerAsync もしくは PushStickerAsync を使用します。
packageId と stickerId は 送信可能なスタンプリスト を参照してください.

await LineMessagingClient.ReplyStickerAsync("replyToken", "packageId", "stickerId");
await LineMessagingClient.PushStickerAsync("to", "packageId", "stickerId");

画像メッセージ

ReplyImageAsync もしくは PushImageAsync を使用します。
使用可能な画像URLは こちら を参照してください。

await LineMessagingClient.ReplyImageAsync("replyToken", "originalContentUrl", "previewImageUrl");
await LineMessagingClient.PushImageAsync("to", "originalContentUrl", "previewImageUrl");

動画メッセージ

ReplyVideoAsync もしくは PushVideoAsync を使用します。
使用可能な動画URLは こちら を参照してください。

await LineMessagingClient.ReplyVideoAsync("replyToken", "originalContentUrl", "PreviewImageUrl");
await LineMessagingClient.PushVideoAsync("to", "originalContentUrl", "PreviewImageUrl");

音声メッセージ

ReplyAudioAsync もしくは PushAudioAsync を使用します。
MessagingAPI では M4A のみサポートしています。MP3ファイル等をお使いの場合は FFmpeg などのサービスをご利用ください。

await LineMessagingClient.ReplyAudioAsync("replyToken", "originalContentUrl", 2000);
await LineMessagingClient.PushAudioAsync("to", "originalContentUrl", 2000);

位置情報メッセージ

ReplyLocationAsync もしくは PushLocationAsync を使用します。

await LineMessagingClient.ReplyLocationAsync("replyToken", "title", "address", (decimal)35.687574, (decimal)139.72922);
await LineMessagingClient.PushLocationAsync("to", "title", "address", (decimal)35.687574, (decimal)139.72922);

イメージマップメッセージ

実装済みです。
執筆中

テンプレートメッセージ

実装済みです。
執筆中

Flexメッセージ

ReplyFlexMessageAsync もしくは PushLocationAsync を使用します。

await LineMessagingClient.ReplyFlexMessageAsync("replyToken", "altText", content);
await LineMessagingClient.PushFlexMessageAsync("to", "altText", content);

複数メッセージを送信する場合

ReplyMessageAsync もしくは PushMessageAsync を使用します。
同時に配信できるメッセージは 5件 です。

var messages = new ISendMessage[]
{
    new TextMessage("HelloWorld"),
    new StickerMessage("446","1988")
};
await LineMessagingClient.ReplyMessageAsync("replyToken", messages);
await LineMessagingClient.PushMessageAsync("to", messages);

画像のようなFlex Messageを作成する場合
image

var content = new BubbleContainer()
{
    Hero = new ImageComponent("https://scdn.line-apps.com/n/channel_devcenter/img/fx/01_1_cafe.png")
    {
        Size = "full",
        AspectRatio = "20:13",
        AspectMode = AspectMode.Cover,
        Action = new UriTemplateAction("http://linecorp.com/")
    },
    Body = new BoxComponent(BoxLayout.Vertical)
    {
        Contents = new IFlexComponent[]
        {
            new TextComponent("Brown Cafe")
            {
                Weight = Weight.Bold,
                Size = "xl"
            },
            new BoxComponent(BoxLayout.Baseline)
            {
                Margin = "md",
                Contents = new IFlexComponent[]
                {
                    new IconComponent("https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png")
                    {
                        Size = "sm"
                    },
                    new IconComponent("https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png")
                    {
                        Size = "sm"
                    },
                    new IconComponent("https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png")
                    {
                        Size = "sm"
                    },
                    new IconComponent("https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png")
                    {
                        Size = "sm"
                    },
                    new IconComponent("https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gray_star_28.png")
                    {
                        Size = "sm"
                    },
                    new TextComponent("4.0")
                    {
                        Size = "sm",
                        Color = "#999999",
                        Margin = "md",
                        Flex = 0
                    }
                }
            },
            new BoxComponent(BoxLayout.Vertical)
            {
                Margin = "lg",
                Spacing = "sm",
                Contents= new IFlexComponent[]
                {
                    new BoxComponent(BoxLayout.Baseline)
                    {
                        Contents= new IFlexComponent[]
                        {
                            new TextComponent("Place")
                            {
                                Color = "#aaaaaa",
                                Size = "sm",
                                Flex = 1
                            },
                            new TextComponent("Miraina Tower, 4-1-6 Shinjuku, Tokyo")
                            {
                                Wrap = true,
                                Color = "#666666",
                                Size = "sm",
                                Flex = 5
                            }
                        }
                    },
                    new BoxComponent(BoxLayout.Baseline)
                    {
                        Spacing = "sm",
                        Contents = new IFlexComponent[]
                        {
                            new TextComponent("Time")
                            {
                                Color = "#aaaaaa",
                                Size = "sm",
                                Flex = 1
                            },
                            new TextComponent("10:00 - 23:00")
                            {
                                Wrap = true,
                                Color = "#666666",
                                Size = "sm",
                                Flex = 5
                            }
                        }
                    }
                }
            }

        }
    },
    Footer = new BoxComponent(BoxLayout.Vertical)
    {
        Spacing = "sm",
        Contents = new IFlexComponent[]
        {
            new ButtonComponent()
            {
                Style = ButtonStyle.Link,
                Height = "sm",
                Action = new UriTemplateAction("https://linecorp.com")
                {
                    Label = "CALL"
                }
            },
            new ButtonComponent()
            {
                Style = ButtonStyle.Link,
                Height = "sm",
                Action = new UriTemplateAction("https://linecorp.com")
                {
                    Label = "WEBSITE"
                }
            },
            new BoxComponent(BoxLayout.Vertical)
            {
                Margin = "sm"
            }
        }
    }
};
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.2.2 1,131 3/8/2023
2.2.1 1,460 4/25/2022
2.2.0 870 3/28/2022
2.1.5 928 2/23/2022
2.1.4 1,184 11/21/2021
2.1.3 846 9/20/2021
2.1.2-bate 668 9/1/2021
2.1.1-bate 656 8/31/2021
2.1.0 768 9/20/2021
2.1.0-bate 669 8/31/2021
2.0.0 1,492 4/29/2021