我正在努力从我的c#项目向诺基亚手机发送推送消息,我已经把我的代码中所需的所有变量都放了,但我处理错误错误请求,我不明白它的原因。
这是我的代码:
private void button1_Click(object sender, EventArgs e)
{
//notification ID string i will get i from OVI
notID = System.Web.HttpUtility.UrlEncode(notID);
string url = "https://alpha.one.ovi.com/nnapi/1.0/nid/" +(notID);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "POST";
request.Credentials = new NetworkCredential(ServiceId, service_secret);
request.ContentType = "application/x-www-form-urlencoded";
request_parameters = System.Web.HttpUtility.UrlEncode(request_parameters);
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] buffer = encoding.GetBytes(request_parameters);
Stream newStream = request.GetRequestStream();
newStream.Write(buffer, 0, buffer.Length);
newStream.Close();
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream);
MessageBox.Show("response=========" + sr.ReadToEnd());
sr.Close();
resStream.Close();
}
else
{
MessageBox.Show("message====" + response.StatusCode);
}
}
}
答案 0 :(得分:0)
请检查以下项目:https://projects.forum.nokia.com/dotnet_notifications_api
它是Nokia Notifications API的.NET包装器。