Web interface for texting, calling

Source: Internet
Author: User

Cloud News: Http://www.ucpaas.com/price

China Network built: http://sms.webchinese.cn/api.shtml test when found that SMS reached too long delay, no way to use.

Cloud Communications: http://www.yuntongxun.com/

I use the cloud as a third party for my communications, and the platform provides detailed interface instructions and tariff instructions.

To their official website can be downloaded to C # demo, in the course of my development found that their demo is missing a voice phone,

According to their agreement, wrote a "Cloud Voice notification Protocol"

 /// <summary>            ///Telephone language Reminders/// </summary>            /// <param name= "Tophone" >called number, can be a normal mobile phone number, fixed number, called as a landline when you need to add area code, such as: 075512345678. </param>            /// <param name= "Tosernum" >The number that is displayed by the called Side of the Voice notification. can display mobile phone number, No. 400 number or landline. Check the rules for the explicit numbers. </param>            /// <param name= "type" >content Type: 0: text; 1: Voice ID</param>            /// <param name= "Content" >when type is 0 o'clock: text content, the platform is responsible for turning the content into speech, calling the specified number, playing the voice file, and when type is 1 o'clock: Indicates the Voice ID (voice file must be uploaded first). </param>            /// <param name= "Playtimes" >The number of cycles played, 1-3 times, played 1 times by default. </param>            /// <returns>Package Body Contents</returns>             Public stringCallupsomebody (stringTophone,stringTosernum,stringTypestringContentstringplaytimes) {                if(Tophone = =NULL)                {                    Throw NewArgumentNullException ("Tophone"); }                Try                {                    stringDate = DateTime.Now.ToString ("YYYYMMDDHHMMSS"); //Build URL Content                    stringSigstr = Md5encrypt (m_mainaccount + M_maintoken +date); stringUristr; stringXML = (M_bodytype = = Ebodytype.etype_xml?)". XML":""); Uristr=string. Format ("https://{0}:{1}/{2}/accounts/{3}/calls/voicenotify{4}?sig={5}", M_restaddress, M_restport, Softver, M_mainaccount, XML, SIGSTR); Uri Address=NewUri (URISTR); Writelog ("CallBack url ="+uristr); //Create a network requestHttpWebRequest request = WebRequest.Create (address) asHttpWebRequest;                    Setcertificatevalidationcallback (); //Build HeadRequest. Method ="POST"; Encoding myencoding= Encoding.GetEncoding ("Utf-8"); byte[] MyByte = myencoding.getbytes (M_mainaccount +":"+date); stringAuthstr =convert.tobase64string (MyByte); Request. Headers.add ("Authorization", AUTHSTR); //Build BodyStringBuilder data =NewStringBuilder (); if(M_bodytype = =ebodytype.etype_xml) {Request. Accept="Application/xml"; Request. ContentType="Application/xml;charset=utf-8"; Data. Append ("<?xml version= ' 1.0 ' encoding= ' utf-8 '?><voicenotify>"); Data. Append ("<appId>"). Append (M_appid). Append ("</appId>"); Data. Append ("<to>"). Append (Tophone). Append ("</to>"); Data. Append ("<type>"). Append (Type). Append ("</type>"); Data. Append ("<content>"). Append (content). Append ("</content>"); Data. Append ("<toSerNum>"). Append (Tosernum). Append ("</toSerNum>"); Data. Append ("<playTimes>"). Append (playtimes). Append ("</playTimes>"); Data. Append ("</voiceNotify>"); }                    Else{request. Accept="Application/json"; Request. ContentType="Application/json;charset=utf-8"; Data. Append ("{"); Data. Append ("\ "Voicenotify\": {"); Data. Append ("\ "appid\": \ ""). Append (M_appid). Append ("\""); Data. Append (", \ "to\": \ ""). Append (Tophone). Append ("\""); Data. Append (", \ "type\": \ ""). Append (Type). Append ("\""); Data. Append (", \ "content\": \ ""). Append (content). Append ("\""); Data. Append (", \ "tosernum\": \ ""). Append (Tosernum). Append ("\""); Data. Append (", \ "playtimes\": \ ""). Append (playtimes). Append ("\""); Data. Append ("}}"); }                    byte[] Bytedata =UTF8Encoding.UTF8.GetBytes (data.                    ToString ()); Writelog ("Createsubaccount requestbody ="+data.                    ToString ()); //Start Request                    using(Stream Poststream =request. GetRequestStream ()) {Poststream.write (bytedata,0, bytedata.length); }                    //GET Request                    using(HttpWebResponse response = Request.) GetResponse () asHttpWebResponse) {                        //Get the response streamStreamReader reader =NewStreamReader (response.                        GetResponseStream ()); stringResponsestr =Reader.                        ReadToEnd (); Writelog ("Createsubaccount responsebody ="+responsestr); if(Responsestr! =NULL&& responsestr.length >0)                        {                            returnResponsestr; }                    }                    return NULL; }                Catch(Exception e) {Throwe; }            }

The demo is provided above. It is more convenient to use.

Web interface for texting, calling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.