Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
Updating Twilio MediaUrl for use with Express 4

I am updating my twilio sms messaging tool to use express 4. On one one line of code I am having an issue.

var mediaUrl = request.param('MediaUrl' + i); //deprecated in express 4

When I attempt to update with this line

var mediaUrl = request.query.MediaUrl + i;

it no longer links to the twilio MediaURL. Here is the complete code for reference.

var numMedia = parseInt( request.body.NumMedia );
if (numMedia > 0) {
    for (i = 0; i < numMedia; i++) {

        //var mediaUrl = request.query.MediaUrl + i;
        var mediaUrl = request.param('MediaUrl' + i); //deprecated in express 4

        groupRef.where( {"memberNumber":request.query.From} ).limit(1).on( "value", function ( data ){
            if( data.count() ){
                data.forEach( function( snapshot ){
                    var member = snapshot.value();
                    messagesRef.push({
                        sid: request.body.MessageSid,
                        type:'text',
                        tstamp: new Date().toLocaleString('en-US', { timeZone: "America/Denver" }),
                        fromName:member.memberName,
                        fromNumber:request.body.From,
                        message:"",
                        media:mediaUrl,
                        groupNumber:request.body.To
                    });
                });
            }
        });
    }
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I think it is due to the fact that Twilio is POSTing the data to you and request.query is looking in the querystring. Either change the Twilio method to GET, or use req.body to get the value from the POST.

The simple fix would be to use:

var mediaUrl = request.body.MediaUrl + i;
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda