Skip to content

Instantly share code, notes, and snippets.

@ko31
Created May 13, 2021 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ko31/cc3c861339215b865c9f4d0300dcc034 to your computer and use it in GitHub Desktop.
Save ko31/cc3c861339215b865c9f4d0300dcc034 to your computer and use it in GitHub Desktop.
How to send a reply text message from the console using the LINE Message API
# via Messaging API reference
# https://developers.line.biz/en/reference/messaging-api/#text-message
# Send text message
curl -v -X POST https://api.line.me/v2/bot/message/push \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {your channel access token}' \
-d '{
"to": "{userId}",
"messages":[
{
"type":"text",
"text":"Hello, world"
}
]
}'
# Send text message with LINE emoji
curl -v -X POST https://api.line.me/v2/bot/message/push \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {your channel access token}' \
-d '{
"to": "{userId}",
"messages":[
{
"type": "text",
"text": "$ LINE emoji $",
"emojis": [
{
"index": 0,
"productId": "5ac1bfd5040ab15980c9b435",
"emojiId": "001"
},
{
"index": 13,
"productId": "5ac1bfd5040ab15980c9b435",
"emojiId": "002"
}
]
}
]
}'
# Send sticker message
curl -v -X POST https://api.line.me/v2/bot/message/push \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {your channel access token}' \
-d '{
"to": "{userId}",
"messages":[
{
"type": "sticker",
"packageId": "446",
"stickerId": "1988"
}
]
}'
# Send image message
curl -v -X POST https://api.line.me/v2/bot/message/push \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {your channel access token}' \
-d '{
"to": "{userId}",
"messages":[
{
"type": "image",
"originalContentUrl": "https://via.placeholder.com/200",
"previewImageUrl": "https://via.placeholder.com/100"
}
]
}'
# Send location message
curl -v -X POST https://api.line.me/v2/bot/message/push \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {your channel access token}' \
-d '{
"to": "{userId}",
"messages":[
{
"type": "location",
"title": "my location",
"address": "1-6-1 Yotsuya, Shinjuku-ku, Tokyo, 160-0004, Japan",
"latitude": 35.687574,
"longitude": 139.72922
}
]
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment