Text API集成问题

编程入门 行业动态 更新时间:2024-10-26 16:31:42
Text API集成问题 - 找不到错误405页面(Text API intergration issue - Error 405 page not found)

我正在使用Innovative Text SMS API网关,这是通过我的错误。

文档可以在链接http://www.innovativetxt.com/services/sms_api_gateway.htm上找到 ,错误发生在我的本地计算机上,但在生产服务器上运行正常。

远程服务器返回错误:(405)方法不允许。

在这行代码:

HttpWebResponse objResponse =(HttpWebResponse)objRequest.GetResponse();

try { // InnovativeTXT POST URL string url = "http://innovativetxt.com/cp/api"; // XML-formatted data string toSender = "4477878585244"; string fromSender = "Test"; string textMessage = "Thanks for Choosing Innovative Text Messaging Solution."; string fields = "?to=" + toSender + "&from=" + fromSender + "&text=" + textMessage + "&api_key=xxx&api_secret=xxxxx"; url = url + fields; // web request start Uri uri = new Uri(url); string data = "field-keywords=ASP.NET 2.0"; if (uri.Scheme == Uri.UriSchemeHttp) { // create a request on behalf of uri HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri); // setting parameter for the request request.Method = WebRequestMethods.Http.Post; request.ContentLength = data.Length; request.ContentType = "application/x-www-form-urlencoded"; // a stream writer for the request StreamWriter writer = new StreamWriter(request.GetRequestStream()); // write down the date writer.Write(data); //close the stream writer writer.Close(); // getting response from the request HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // Get the stream associated with the response. Stream receiveStream = response.GetResponseStream(); // Pipes the stream to a higher level stream reader with the required encoding format. StreamReader readStream = new StreamReader(receiveStream, System.Text.Encoding.UTF8); // to write a http response from the characters Response.Write(readStream.ReadToEnd()); // close the response response.Close(); // close the reader readStream.Close(); } } catch (Exception exp) { // catch for unhelded exception Response.Write(exp.Message); }

I am using Innovative Text SMS API gateway which is through me error.

Documentation is available at link http://www.innovativetxt.com/services/sms_api_gateway.htm, the error is happening on my local machine, but works fine at the production server.

The remote server returned an error: (405) Method Not Allowed.

at this line of code:

HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();

try { // InnovativeTXT POST URL string url = "http://innovativetxt.com/cp/api"; // XML-formatted data string toSender = "4477878585244"; string fromSender = "Test"; string textMessage = "Thanks for Choosing Innovative Text Messaging Solution."; string fields = "?to=" + toSender + "&from=" + fromSender + "&text=" + textMessage + "&api_key=xxx&api_secret=xxxxx"; url = url + fields; // web request start Uri uri = new Uri(url); string data = "field-keywords=ASP.NET 2.0"; if (uri.Scheme == Uri.UriSchemeHttp) { // create a request on behalf of uri HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri); // setting parameter for the request request.Method = WebRequestMethods.Http.Post; request.ContentLength = data.Length; request.ContentType = "application/x-www-form-urlencoded"; // a stream writer for the request StreamWriter writer = new StreamWriter(request.GetRequestStream()); // write down the date writer.Write(data); //close the stream writer writer.Close(); // getting response from the request HttpWebResponse response = (HttpWebResponse)request.GetResponse(); // Get the stream associated with the response. Stream receiveStream = response.GetResponseStream(); // Pipes the stream to a higher level stream reader with the required encoding format. StreamReader readStream = new StreamReader(receiveStream, System.Text.Encoding.UTF8); // to write a http response from the characters Response.Write(readStream.ReadToEnd()); // close the response response.Close(); // close the reader readStream.Close(); } } catch (Exception exp) { // catch for unhelded exception Response.Write(exp.Message); }

最满意答案

此问题与IIS处理程序映射有关。

您应该在字符串URL的末尾指定文件名:

string url = "http://innovativetxt.com/cp/api/somepage.aspx";

您可以使用默认页面,如default.aspx或index.php等...

This issue relates to IIS Handler mappings.

You should specify the file name at the end of string URL:

string url = "http://innovativetxt.com/cp/api/somepage.aspx";

You can use default pages like, default.aspx or index.php etc...

更多推荐

本文发布于:2023-07-29 05:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1312624.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Text   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!