i have configured url receive twiml message. receive following fields
- account sid 2.body 3.from 4.messagesid 5.nummedia
however, dont receive following
- mediacontenttype
- mediaurl
though field nummedia has value 2, dont receive mediaurl.
i use c#.
following class structure hold request message received twilio
public class twiliorequest { public string messagesid { get; set; } public string accountsid { get; set; } public string { get; set; } public string { get; set; } public string body { get; set; } public int nummedia { get; set; } public list<string> mediacontenttype { get; set; } public list<string> mediaurl { get; set; } }
kindly guide me.
when mms message received , contains media (images, videos) indeed put count nummedia
field of post request directed @ server. individual media urls , identifier appended consecutive sequence numbers (up 10) , result in post request having many individual fields, each media content:
"mediacontenttype0" : "", "mediaurl0" :"", "mediacontenttype1" : "", "mediaurl1" :""
upon detection of media in post request (!=0 nummedia
) should iterate on fields retrieve interesting arguments.
please see below sample implementation:
// build name value pairs incoming web hook twilio namevaluecollection nvc = request.form; // type name value pairs string strfrom = nvc["from"]; string strnummedia = nvc["nummedia"]; string strbody = nvc["body"]; // holds image type , link images list<string> listmediaurl = new list<string>(); list<string> listmediatype = new list<string>(); list<stream> listimages = new list< // find if there multimedia content if (int.parse(strnummedia) != 0) { // if there find out media type , image url can pick them (int intcount = 0; intcount < int.parse(strnummedia);) { // store media type image through should same listmediatype.add(nvc[("mediacontenttype" + intcount).tostring()]); // store image there fair chance of getting more 1 image twilio supports 10 in single mms 5mb listmediaurl.add(nvc[("mediaurl" + intcount).tostring()]); // update loop counter intcount = intcount + 1; } }
Comments
Post a Comment