我试图使用REST API使用说明,将增加一个用户的身份到通道:https://www.twilio.com/docs/api/ip-messaging/rest/members#action-createTwilio IP消息用户没有找到
我张贴到/Channels/channelId/Members
终点 - 我敢肯定我的要求是结构正确。
我得到一个错误的Twilio IP消息回话说:
{"code": 50200, "message": "User not found", "more_info": "https://www.twilio.com/docs/errors/50200", "status": 400}
我的理解是,我们可以提供我们自己的身份,当我们想某人添加到一个频道。如何在将用户添加到频道之前“注册”用户(使用电子邮件)?
编辑 - 代码:
var _getRequestBaseUrl = function() {
return 'https://' +
process.env.TWILIO_ACCOUNT_SID + ':' +
process.env.TWILIO_AUTH_TOKEN + '@' +
TWILIO_BASE + 'Services/' +
process.env.TWILIO_IPM_SERVICE_SID + '/';
};
var addMemberToChannel = function(memberIdentity, channelId) {
var options = {
url: _getRequestBaseUrl() + 'Channels/' + channelId + '/Members',
method: 'POST',
headers: {
'content-type': 'application/x-www-form-urlencoded',
},
form: {
Identity: memberIdentity,
},
};
request(options, function(error, response, body) {
if (error) {
// Getting the error here
}
// do stuff with response.
});
};
addMemberToChannel('[email protected]', <validChannelId>);
您可以分享您用于发布POST请求的代码吗? – philnash
@philnash:完成。 – sparkFinder