I. Background of the problem
Following the last seven Qiniu SDK issues (for reference: http://www.cnblogs.com/OMango/p/8447480.html), in the sending of text messages in the function of the problem, we use the SMS service is more than Ali service, the previous platform is. NET The framework of the platform, the use of the official Ali SDK does not appear any moth, but after moving to the. NET core, looking for Ali official also did not find the. NET Core SDK, have to say, in this respect. NET core has a long way to go, although there is no SDK, But the function is still to complete ah, how to do? can only own from. NETFramework's SDK for extraction
Ii. Modification Instructions
Emmmm, after a good look at the SDK and the official documents, found that topsdk inside also contains some other features, but I only need SMS service Ah, so, since the preparation of the other related functions are removed, only left the message related functions, nonsense not to say first on the link https:// Github.com/hello-mango/mtopsdksms.core, which I have modified after the code, also tested can send text messages to the phone, DLL has also been uploaded to NuGet (search mtopsdksms)
The modification scenario is primarily. NET The HttpRequest class under Frmework is not the default band in. Netcore, so you need to install Microsoft.AspNetCore.Http, which also uses a reflection method, so you need to install System.Reflection.Emit.Light Weight, the last point is to
false;
Revision changed to
false;
If not modified, will report the platform does not support the error, if you want to try it yourself, you can download the official SDK source code for. NET core transformation, or you can directly NuGet search mtopsdksms
Third, the specific use
Specific code usage can be fully referenced to the official document use, I will give a simple package code here
PublicSMS (stringPhoneno, String template, String _appkey, String _appsecret, String _extend, String _smsfreesignname, String _smstemp Latecode) {_phoneno=Phoneno; _template=template; Appsecret=_appsecret; Appkey=_appkey; Extend=_extend; Smsfreesignname=_smsfreesignname; Smstemplatecode=_smstemplatecode; } /// <summary> ///SMS Identity Verification/// </summary> /// <param name= "Phoneno" >Phone number</param> /// <param name= "Dicparam" >SMS template variables, corresponding to custom fields in the template</param> /// <returns></returns> PublicString Send () {//short Note API request parametersItopclient client =Newdefaulttopclient (URL, Appkey, Appsecret); Alibabaaliqinfcsmsnumsendrequest req=Newalibabaaliqinfcsmsnumsendrequest (); Req. Extend= Extend;//The public callback parameter, which is passed back in "message return";Req. Smstype ="Normal";//text message type, incoming value please fill in normalReq. Smsfreesignname = Smsfreesignname;//SMS SignatureReq. Smsparam = _template;//SMS Template VariablesReq. Recnum = _phoneno;//SMS Receive numberReq. Smstemplatecode = Smstemplatecode;//SMS Template IDAlibabaaliqinfcsmsnumsendresponse response = client. Execute<alibabaaliqinfcsmsnumsendresponse>(req); if(Response. Result = =NULL) { returngeterrormsg (response. Suberrcode); } Else { returnResponse. Result.Success.ToString (); } }
Iv. Summary
The. NET core is currently supported on third-party libraries relatively small, such as Oracle does not currently have a drive library on. NET core, and some simple encounters can only be done on their own to convert or other ways to achieve, but the follow-up believe that. NET core will be better
PS: Because this is only my personal modification works, has not been a lot of verification, if you find any problem, please contact me.
Mango
Source: http://www.cnblogs.com/OMango/
About yourself: focus. NET desktop development and web background development, start to touch microservices, Docker and other Internet-related
This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph of the statement, and in the article page obvious location give the original link, if there is a problem, can mail ([email protected]) Consulting.
. NET Core Ali is larger than SMS Send SDK modifications and uses