I have solved my own issue. By replacing .getProfile with .getGroupMemberProfile seems to have worked. :)
So I have investigated further into this and trying this code now - https://developers.line.biz/en/reference/messaging-api/#get-group-member-profile
I will be modifying my value of .getProfile to .getGroupMemberProfile and see if this fixes my problem.
Hi Shoya,
Sure No Problems, Please see below:
Code:
function debug_check(e) {
45 var d = new Date(e.timestamp);
46 console.log("Event Time Stamp:" + d);
47 console.log("Event Source User ID:"+ e.source.userId);
48 client.getProfile(e.source.userId).then((profile) => {
49 console.log("Profile Display Name:"+ profile.displayName);
50 //console.log("Profile User ID:"+ profile.userId);
51 //console.log("Profile Picture URL:"+ profile.pictureUrl);
52 //console.log("Profile Status Message:"+ profile.statusMessage);
53 })
54 .catch((err) => {
55 console.log(err.message);
56 });
57 //console.log("Event Source Room ID:"+ e.source.roomId);
58 console.log("Event Source Group ID:"+ e.source.groupId);
59 console.log("Event Type:"+ e.type);
60 console.log("Event Message ID:"+ e.message.id);
61 console.log("Event Message Type:"+ e.message.type);
62 }
Output from console log - Working Reply With Profile Name (I have modified the User ID, Group ID)
2018-11-28T02:06:33.959943+00:00 app[web.1]: Event Time Stamp:Wed Nov 28 2018 02:06:33 GMT+0000 (Coordinated Universal Time)
2018-11-28T02:06:33.960059+00:00 app[web.1]: Event Source User ID:11111111111111111111
2018-11-28T02:06:33.962477+00:00 app[web.1]: Event Source Group ID:1111111111111111111
2018-11-28T02:06:33.962939+00:00 app[web.1]: Event Type:message
2018-11-28T02:06:33.963006+00:00 app[web.1]: Event Message ID:11111111111
2018-11-28T02:06:33.963283+00:00 app[web.1]: Event Message Type:text
2018-11-28T02:06:33.963353+00:00 app[web.1]: In:I like pie
2018-11-28T02:06:33.963476+00:00 app[web.1]: Decipher:i,like,pie
2018-11-28T02:06:34.357791+00:00 app[web.1]: Profile Display Name:HarK UTC+8
Out from Console Log - Not working Reply with Profile Name
2018-11-28T02:10:10.846876+00:00 app[web.1]: Event Time Stamp:Wed Nov 28 2018 02:10:10 GMT+0000 (Coordinated Universal Time)
2018-11-28T02:10:10.846902+00:00 app[web.1]: Event Source User ID:22222222222222222
2018-11-28T02:10:10.846996+00:00 app[web.1]: Event Source Group ID:11111111111111111
2018-11-28T02:10:10.847004+00:00 app[web.1]: Event Type:message
2018-11-28T02:10:10.847054+00:00 app[web.1]: Event Message ID:1111111111111111
2018-11-28T02:10:10.847060+00:00 app[web.1]: Event Message Type:text
2018-11-28T02:10:10.847112+00:00 app[web.1]: In:I like pie too hark
2018-11-28T02:10:10.847162+00:00 app[web.1]: Decipher:i,like,pie,too,hark
2018-11-28T02:10:11.040747+00:00 app[web.1]: Request failed with status code 404
From further testing I can see that the profile request only works if it is "my account" But if I try to retrieve anyone else's account in the "Group Chat" i will get a 404 error. Very weird.
Can I show your part of code?