我試圖使用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