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

发布于 2025-01-03 17:53:49 字数 1543 浏览 1 评论 0原文

我正在努力从我的 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);

            }
        }


    }

i am working to sent a push message to Nokia phone from my c# project and i already put all the variables needed in my code but i handle an error Bad Request, i didn't understand its reason.

Here is my code:

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

            }
        }


    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愛放△進行李 2025-01-10 17:53:49

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

它是诺基亚通知 API 的 .NET 包装器。

Please check the following project: https://projects.forum.nokia.com/dotnet_notifications_api

It is a .NET wrapper for the Nokia Notifications API.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文