错误 - 作为问号收到的移动消息 [英] Error - Mobile Message Received as Question Marks
本文介绍了错误 - 作为问号收到的移动消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在尝试向手机发送消息
我正在使用InnovativeTXT.com SMS API
消息文本是阿拉伯语
i收到消息成功但消息显示为??????? ??????? ???????''
如何解决这个问题?
我的守则是:
public static string Send_SMS( string To_Sender, string From_Sender, string Message_Text)
{
string MSG = < span class =code-keyword> string .Empty;
尝试
{
// InnovativeTXT POST URL
string url = http://innovativetxt.com/cp/api/index.php跨度>;
/// API密钥和API密码适用于amr_deif700@yahoo.com ACCOUNT
string API_Key = u9khsfbg 跨度>;
string API_Secret = 2kr0qz40跨度>;
string fields = ?to = + To_Sender + & from = + From_Sender + & text = + Message_Text + & api_key = + API_Key + & api_secret = + API_Secret + ;
url = url + fields;
// 网络请求开始
Uri uri = new Uri(url);
string data = field-keywords = ASP.NET 2.0;
if (uri.Scheme == Uri.UriSchemeHttp)
{
// 代表uri创建请求
HttpWebRequest request =(HttpWebRequest)HttpWebRequest.Create(uri);
// 请求的设置参数
request.Method = WebRequestMethods.Http .POST;
request.ContentLength = data.Length;
request.ContentType = application / x-www-form-urlencoded;
// 请求的流编写器
StreamWriter writer = new StreamWriter(request.GetRequestStream());
// 记下日期
writer.Write(data);
// 关闭流编写器
writer.Close();
// 从请求中获取响应
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// 获取与响应关联的流。
流receiveStream = response.GetResponseStream();
// 使用所需的编码格式将流管道传输到更高级别的流阅读器。 / span>
StreamReader readStream = new StreamReader(receiveStream,System.Text.Encoding.UTF8);
// 从字符中写出一个http响应
MSG = readStream.ReadToEnd();
// 关闭响应
response.Close();
// 关闭阅读器
readStream.Close();
}
返回 MSG;
}
catch (Exception exp)
{
// catch for unhelded exception
MSG = exp.Message;
返回 MSG;
}
}
任何IDEAS PLZ ...
解决方案
感谢 Prasad Khandekar 回复
我联系了我的SMS提供商,他们给了我写的回答添加此代码:
& type = unicode
到URL字符串,现在工作正常
Hi Everyone,
I''m trying to send message to my mobile phone
i''m using InnovativeTXT.com SMS API
the message text is in arabic
i receive the message successfully but the message appears like this ''??????? ??????? ???????''
how can i solve this?
My Code is:
public static string Send_SMS(string To_Sender, string From_Sender, string Message_Text)
{
string MSG = string.Empty;
try
{
// InnovativeTXT POST URL
string url = "http://innovativetxt.com/cp/api/index.php";
///API Key And API Secret are for amr_deif700@yahoo.com ACCOUNT
string API_Key = "u9khsfbg";
string API_Secret = "2kr0qz40";
string fields = "?to=" + To_Sender + "&from=" + From_Sender + "&text=" + Message_Text + "&api_key=" + API_Key + "&api_secret=" + API_Secret + "";
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
MSG = readStream.ReadToEnd();
// close the response
response.Close();
// close the reader
readStream.Close();
}
return MSG;
}
catch (Exception exp)
{
// catch for unhelded exception
MSG = exp.Message;
return MSG;
}
}
Any IDEAS plz...
解决方案
Thanks Prasad Khandekar for your reply
I contacted My SMS Providers and they gave me the write answer which is to add this code:
&type=unicode
to the URL String and it works fine now.
这篇关于错误 - 作为问号收到的移动消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文