LINEAPI
in package
LINEAPI (Messaging API)
This is the Messaging API for creating LINE Chat BOTs.
Tags
Table of Contents
- API_DATA_HOST = "https://api-data.line.me"
- The host is used for uploading/downloading objects from LINE API Platform.
- API_HOST = "https://api.line.me"
- The host is used for connecting the primary service of LINE API Platform.
- HTTP_METHOD_DELETE = 2
- HTTP Delete Method
- HTTP_METHOD_GET = 0
- HTTP Get Method
- HTTP_METHOD_POST = 1
- HTTP Post Method
- $responseDecodeAsArray : bool
- If read the response as array while decoding JSON in `requestFactory`.
- $channelAccessToken : string|null
- The value is set for authorizing while the API connecting LINE API Platform.
- $channelSecret : string|null
- The value is set for verifying signatures that whether the requests were sent from the LINE API Platform.
- __construct() : mixed
- LINEAPI constructor.
- broadcast() : object
- Send broadcast message.
- confirmingAudienceGroupStatus() : object
- Confirming that an audience is ready to accept messages.
- createRichMenu() : object
- Create rich menu.
- deleteRichMenu() : object
- Delete rich menu.
- downloadMessageObject() : bool
- Save file of the message from the function `getMessageObject`.
- downloadRichMenuImage() : bool
- Save image of the rich menu from the function `getRichMenuImage`.
- getAllMessagesSentCount() : object
- Get number of messages sent this month.
- getBroadcastMessagesSentCount() : object
- Get number of sent broadcast messages.
- getFollowersCount() : object
- Get number of followers.
- getFollowersIds() : object
- Get the user ID of all users who added your LINE Official Accout as a friend.
- getFriendDemographics() : object
- Get friend demographics.
- getGroup() : object
- Get group summary.
- getGroupMemberCount() : object
- Get number of users in a group.
- getGroupMemberIds() : object
- Get group member user IDs.
- getGroupMemberInfo() : object
- Get group member profile.
- getMessageDeliveriesCount() : object
- Get number of message deliveries.
- getMessageObject() : string|null
- Download content of the message. (Get the raw data only)
- getMulticastMessagesSentCount() : object
- Get number of sent multicast messages.
- getProfile() : object
- Get profile.
- getPushMessagesSentCount() : object
- Get number of sent push messages.
- getReplyMessagesSentCount() : object
- Get number of sent reply messages.
- getRichMenu() : object
- Get rich menu.
- getRichMenuIdOfUser() : object
- Get rich menu ID of user.
- getRichMenuImage() : string|null
- Download rich menu image. (Get the raw data only)
- getRichMenuList() : object
- Get rich menu list.
- getRoomMemberCount() : object
- Get number of users in a room.
- getRoomMemberIds() : object
- Get room member profile.
- getRoomMemberInfo() : object
- Get room member user IDs.
- getSendMessagesQuota() : object
- Get the target limit for additional messages.
- getUserInteractionStatistics() : object
- Get user interaction statistics.
- issueChannelAccessToken() : object
- Issue channel access token.
- issueUserLinkToken() : object
- Issue link token.
- leaveGroup() : object
- Leave group.
- leaveRoom() : object
- Leave room.
- linkRichMenuToUser() : object
- Link rich menu to user.
- multicast() : object
- Send multicast message.
- parseEvents() : array<string|int, mixed>
- Verify the request which visits this API, if it's from LINE Webhook, parse the events.
- pushMessage() : object
- Send push message.
- replyMessage() : object
- Send reply message.
- revokeChannelAccessToken() : bool
- Revoke channel access token.
- unlinkRichMenuFromUser() : object
- Unlink rich menu from user.
- uploadRichMenuImage() : void
- Upload rich menu image. (libcURL used)
- requestFactory() : mixed
- Send request to LINE API Platform.
- sign() : string
- Signing data via SHA-256.
Constants
API_DATA_HOST
The host is used for uploading/downloading objects from LINE API Platform.
public
string
API_DATA_HOST
= "https://api-data.line.me"
API_HOST
API_HOST
The host is used for connecting the primary service of LINE API Platform.
public
string
API_HOST
= "https://api.line.me"
API_HOST
HTTP_METHOD_DELETE
HTTP Delete Method
public
int
HTTP_METHOD_DELETE
= 2
The constant is used for
requestFactory
to set the HTTP Method while transporting.
HTTP_METHOD_DELETE
HTTP_METHOD_GET
HTTP Get Method
public
int
HTTP_METHOD_GET
= 0
The constant is used for
requestFactory
to set the HTTP Method while transporting.
HTTP_METHOD_GET
HTTP_METHOD_POST
HTTP Post Method
public
int
HTTP_METHOD_POST
= 1
The constant is used for
requestFactory
to set the HTTP Method while transporting.
HTTP_METHOD_POST
Properties
$responseDecodeAsArray
If read the response as array while decoding JSON in `requestFactory`.
public
bool
$responseDecodeAsArray
= alse
The default is exporting as Object, set value to true
that it will use Array.
$channelAccessToken
The value is set for authorizing while the API connecting LINE API Platform.
private
string|null
$channelAccessToken
If you don't have the Authorized Tokens, following the guide of the URL to generate one.
Tags
$channelSecret
The value is set for verifying signatures that whether the requests were sent from the LINE API Platform.
private
string|null
$channelSecret
Tags
Methods
__construct()
LINEAPI constructor.
public
__construct( $channelAccessToken, $channelSecret) : mixed
This is the constructor of API, to initialize your certificates into it. If you need to use issueChannelAccessToken, you can set both of them as null, issueChannelAccessToken will setup the values automatically.
Parameters
Return values
mixed —broadcast()
Send broadcast message.
public
broadcast(array<string|int, mixed> $message[, bool $notificationDisabled = false ]) : object
Parameters
- $message : array<string|int, mixed>
- $notificationDisabled : bool = false
-
(optional)
Tags
Return values
object —confirmingAudienceGroupStatus()
Confirming that an audience is ready to accept messages.
public
confirmingAudienceGroupStatus(string $audienceGroupId) : object
Parameters
- $audienceGroupId : string
Tags
Return values
object —createRichMenu()
Create rich menu.
public
createRichMenu(string $content) : object
Parameters
- $content : string
Tags
Return values
object —deleteRichMenu()
Delete rich menu.
public
deleteRichMenu(string $richMenuId) : object
Parameters
- $richMenuId : string
Tags
Return values
object —downloadMessageObject()
Save file of the message from the function `getMessageObject`.
public
downloadMessageObject(string $messageId[, string $path = "./" ]) : bool
Parameters
- $messageId : string
- $path : string = "./"
-
(optional)
Return values
bool —If it success, will return true
.
downloadRichMenuImage()
Save image of the rich menu from the function `getRichMenuImage`.
public
downloadRichMenuImage(string $richMenuId[, string $path = "./" ]) : bool
Parameters
- $richMenuId : string
- $path : string = "./"
-
(optional)
Return values
bool —If it success, will return true
.
getAllMessagesSentCount()
Get number of messages sent this month.
public
getAllMessagesSentCount() : object
Tags
Return values
object —getBroadcastMessagesSentCount()
Get number of sent broadcast messages.
public
getBroadcastMessagesSentCount() : object
Tags
Return values
object —getFollowersCount()
Get number of followers.
public
getFollowersCount(string $date) : object
Parameters
- $date : string
Tags
Return values
object —getFollowersIds()
Get the user ID of all users who added your LINE Official Accout as a friend.
public
getFollowersIds([string $continuationToken = "" ]) : object
Parameters
- $continuationToken : string = ""
-
(optional)
Tags
Return values
object —getFriendDemographics()
Get friend demographics.
public
getFriendDemographics() : object
Tags
Return values
object —getGroup()
Get group summary.
public
getGroup(string $groupId) : object
Parameters
- $groupId : string
Tags
Return values
object —getGroupMemberCount()
Get number of users in a group.
public
getGroupMemberCount(string $groupId) : object
Parameters
- $groupId : string
Tags
Return values
object —getGroupMemberIds()
Get group member user IDs.
public
getGroupMemberIds(string $groupId[, string $continuationToken = "" ]) : object
Parameters
- $groupId : string
- $continuationToken : string = ""
-
(optional)
Tags
Return values
object —getGroupMemberInfo()
Get group member profile.
public
getGroupMemberInfo(string $groupId, string $userId) : object
Parameters
- $groupId : string
- $userId : string
Tags
Return values
object —getMessageDeliveriesCount()
Get number of message deliveries.
public
getMessageDeliveriesCount(string $date) : object
Parameters
- $date : string
Tags
Return values
object —getMessageObject()
Download content of the message. (Get the raw data only)
public
getMessageObject(string $messageId) : string|null
Parameters
- $messageId : string
Tags
Return values
string|null —getMulticastMessagesSentCount()
Get number of sent multicast messages.
public
getMulticastMessagesSentCount() : object
Tags
Return values
object —getProfile()
Get profile.
public
getProfile(string $userId) : object
Parameters
- $userId : string
Tags
Return values
object —getPushMessagesSentCount()
Get number of sent push messages.
public
getPushMessagesSentCount() : object
Tags
Return values
object —getReplyMessagesSentCount()
Get number of sent reply messages.
public
getReplyMessagesSentCount() : object
Tags
Return values
object —getRichMenu()
Get rich menu.
public
getRichMenu(string $richMenuId) : object
Parameters
- $richMenuId : string
Tags
Return values
object —getRichMenuIdOfUser()
Get rich menu ID of user.
public
getRichMenuIdOfUser(string $userId) : object
Parameters
- $userId : string
Tags
Return values
object —getRichMenuImage()
Download rich menu image. (Get the raw data only)
public
getRichMenuImage(string $richMenuId) : string|null
Parameters
- $richMenuId : string
Tags
Return values
string|null —getRichMenuList()
Get rich menu list.
public
getRichMenuList() : object
Tags
Return values
object —getRoomMemberCount()
Get number of users in a room.
public
getRoomMemberCount(string $roomId) : object
Parameters
- $roomId : string
Tags
Return values
object —getRoomMemberIds()
Get room member profile.
public
getRoomMemberIds(string $roomId[, string $continuationToken = "" ]) : object
Parameters
- $roomId : string
- $continuationToken : string = ""
-
(optional)
Tags
Return values
object —getRoomMemberInfo()
Get room member user IDs.
public
getRoomMemberInfo(string $roomId, string $userId) : object
Parameters
- $roomId : string
- $userId : string
Tags
Return values
object —getSendMessagesQuota()
Get the target limit for additional messages.
public
getSendMessagesQuota() : object
Tags
Return values
object —getUserInteractionStatistics()
Get user interaction statistics.
public
getUserInteractionStatistics(string $requestId) : object
Parameters
- $requestId : string
Tags
Return values
object —issueChannelAccessToken()
Issue channel access token.
public
issueChannelAccessToken(string $channelId, string $channelSecret) : object
Parameters
- $channelId : string
- $channelSecret : string
Tags
Return values
object —issueUserLinkToken()
Issue link token.
public
issueUserLinkToken(string $userId) : object
Parameters
- $userId : string
Tags
Return values
object —leaveGroup()
Leave group.
public
leaveGroup(string $groupId) : object
Parameters
- $groupId : string
Tags
Return values
object —leaveRoom()
Leave room.
public
leaveRoom(string $roomId) : object
Parameters
- $roomId : string
Tags
Return values
object —linkRichMenuToUser()
Link rich menu to user.
public
linkRichMenuToUser(string $userId, string $richMenuId) : object
Parameters
- $userId : string
- $richMenuId : string
Tags
Return values
object —multicast()
Send multicast message.
public
multicast(array<string|int, mixed> $targetIds, array<string|int, mixed> $message[, bool $notificationDisabled = false ]) : object
Parameters
- $targetIds : array<string|int, mixed>
- $message : array<string|int, mixed>
- $notificationDisabled : bool = false
-
(optional)
Tags
Return values
object —parseEvents()
Verify the request which visits this API, if it's from LINE Webhook, parse the events.
public
parseEvents() : array<string|int, mixed>
Return values
array<string|int, mixed> —pushMessage()
Send push message.
public
pushMessage(string $targetId, array<string|int, mixed> $message[, bool $notificationDisabled = false ]) : object
Parameters
- $targetId : string
- $message : array<string|int, mixed>
- $notificationDisabled : bool = false
-
(optional)
Tags
Return values
object —replyMessage()
Send reply message.
public
replyMessage(string $replyToken, array<string|int, mixed> $message[, bool $notificationDisabled = false ]) : object
Parameters
- $replyToken : string
- $message : array<string|int, mixed>
- $notificationDisabled : bool = false
-
(optional)
Tags
Return values
object —revokeChannelAccessToken()
Revoke channel access token.
public
revokeChannelAccessToken([string $channelAccessToken = "" ]) : bool
Parameters
- $channelAccessToken : string = ""
-
Specify a channel access token you hope to revoke. (optional)
Tags
Return values
bool —If it success, will return true
.
unlinkRichMenuFromUser()
Unlink rich menu from user.
public
unlinkRichMenuFromUser(string $userId, string $richMenuId) : object
Parameters
- $userId : string
- $richMenuId : string
Tags
Return values
object —uploadRichMenuImage()
Upload rich menu image. (libcURL used)
public
uploadRichMenuImage(string $richMenuId, string $path) : void
Parameters
- $richMenuId : string
- $path : string
Tags
Return values
void —requestFactory()
Send request to LINE API Platform.
private
requestFactory(string $targetUri, int $method[, mixed $data = array() ][, bool $decode = true ]) : mixed
Parameters
- $targetUri : string
-
An URL for sending request.
- $method : int
-
HTTP Method.
- $data : mixed = array()
-
Content for doing POST. (optional)
- $decode : bool = true
-
Decode the response from JSON. (optional)
Return values
mixed —sign()
Signing data via SHA-256.
private
sign(mixed $body) : string
Parameters
- $body : mixed