使用c#为诺基亚nid推送通知

本文关键字:通知 nid 诺基亚 使用 | 更新日期: 2023-09-27 18:23:48

我正在从我的c#项目向诺基亚手机发送推送消息,我已经在代码中放入了所有需要的变量,但我处理了一个错误Bad Request,我不明白它的原因。

这是我的代码:

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);
            }
        }

    }

使用c#为诺基亚nid推送通知

请检查以下项目:https://projects.forum.nokia.com/dotnet_notifications_api

它是适用于诺基亚通知API的.NET包装。