How to Get a LINE User MID

When getting started with LINE API messaging, you need to know the mid of a message recipient. It’s not his/her username. It’s a string that looks like ub8dbd4a12c322f6c0118883d839c55a4.

LINE utilizes a callback URL that you can set for your trial LINE bot. At this endpoint you can place a script, shown below, which will report your mid back to you when you type “whoami”.

LINE Bot mid response
LINE mid

You need the LINE PHP SDK installed for this script below. I recommend installing it with composer.

After you have installed the SDK and have created your trial LINE bot account, register a callback URL as per the API instructions (e.g.

LINE callback URL
Register a LINE callback URL

After that, using whichever device has the account of the mid you wish to know, scan the QR code in the Channel Console and add your trial LINE bot to your LINE account. After you have added your trial LINE bot as your friend, send “whoami” to it.

This above script is a simple bootstrap to make a more functional bot, and it incorporates the recommended signature verification.