Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twilio “更新消息”;属性“;使用JSON作为消息类型媒体_Twilio_Twilio Php_Twilio Programmable Chat - Fatal编程技术网

Twilio “更新消息”;属性“;使用JSON作为消息类型媒体

Twilio “更新消息”;属性“;使用JSON作为消息类型媒体,twilio,twilio-php,twilio-programmable-chat,Twilio,Twilio Php,Twilio Programmable Chat,由于不支持媒体消息,im被迫采取变通措施,将文件内容存储在s3存储桶中,并使用s3的链接更新媒体消息 Im使用以下代码更新媒体消息 http://localhost:8051/channel/CHe1XXXXXXXXXXXXXXXXX/messages/IMdb99326ebf7dXXXXXXXXXXXX exports.updateMessage = async function (channelSID, messageSID, body) { const messageObj =

由于不支持媒体消息,im被迫采取变通措施,将文件内容存储在s3存储桶中,并使用s3的链接更新媒体消息

Im使用以下代码更新媒体消息

http://localhost:8051/channel/CHe1XXXXXXXXXXXXXXXXX/messages/IMdb99326ebf7dXXXXXXXXXXXX

exports.updateMessage = async function (channelSID, messageSID, body) {
    const messageObj = body;
    const message = twilioClient.chat.services(variables.twilioServiceSID)
        .channels(channelSID)
        .messages(messageSID)
        .update({
            messageObj
        })
        .then(message => {
            return message;
        })
    return message;
};
请求机构:

{
 "attributes": 
     { "s3_url": "https://testingbucket.s3.us-east-2.amazonaws.com/fileupload" }
 }
答复:

{"name":"test-adapter","hostname":"Abinaya","pid":14696,"level":30,"res":{"statusCode":200,"responseTime":1303,"headers":{"x-request-id":"4eb0077e-53e9-4965-9eb8-f0c314444d09","content-type":"application/json; charset=utf-8"}},"event":"response","body":{"status":"success","data":{"sid":"IMdb99326ebf7XXXXXXXXXXXXXX","attributes":"{}","to":"CHe16335c4a04643XXXXXXXXXXXXX","channelSid":"CHe16335c4a04XXXXXXXXXXXX","dateCreated":"2019-11-29T13:26:20.000Z","dateUpdated":"2019-12-02T09:31:58.000Z","lastUpdatedBy":"system","wasEdited":true,"from":"chintakindisantosh@gmail.com","body":null,"index":20,"type":"media","media":{"size":119238,"filename":"dominos.png","content_type":"image/png","sid":"MEb683c0cd51391f4bXXXXXXXXXX"}},"message":"Message updated successfully"},"msg":"request end","time":"2019-12-02T09:31:58.669Z","v":0}

即使在收到200 OK后,媒体消息也不会更新。

上述问题的解决方案

属性应该是一个字符串,在里面我们可以给出JSON

interface ChannelListInstanceCreateOptions {
  attributes?: string;
  createdBy?: string;
  dateCreated?: Date;
  dateUpdated?: Date;
  friendlyName?: string;
  type?: ChannelChannelType;
  uniqueName?: string;
}
例如,我们可以给出如下的例子

attributes : '{"clientName":"Test"}'