【问题标题】:Pushwoosh, Sending a push message using vb.net and jsonPushwoosh,使用 vb.net 和 json 发送推送消息
【发布时间】:2013-08-22 06:24:16
【问题描述】:

我必须使用 pushwoosh api 向设备发送消息。我从 vb.net 发送它,我有一个高级帐户。该代码工作正常,但我从服务器返回代码 400。有什么想法吗?

我的 json 请求如下所示:

{   
    'request':
    {
'application':'xxxxx-xxxxx',                 
    'auth':'xxxxx',
        'notifications':[{
             'send_date':'now',     
             'ignore_user_timezone': true,     
             'content':'Hallo world'   
             }]
     }
}

VB.net 代码:

电话:

dim JsonSring = "{'request':{'application':'My app id','auth':'api key','notifications':[ { 'send_date':'now', 'ignore_user_timezone' : true, '内容':'你好世界' } ]}}"

将 myUri 调暗为新 Uri("https://cp.pushwoosh.com/json/1.3/")

暗数据 = Encoding.UTF8.GetBytes(jsonSring)

Dim result_post = MyFunctions.SendRequest(myUri, data, "application/json", "POST")

功能:

公共共享函数 SendRequest(uri As Uri, jsonDataBytes As Byte(), contentType As String, method As String) As String

    Dim req As WebRequest = WebRequest.Create(uri)

    req.ContentType = contentType

    req.Method = method

    req.ContentLength = jsonDataBytes.Length



    Dim stream = req.GetRequestStream()
    stream.Write(jsonDataBytes, 0, jsonDataBytes.Length)
    stream.Close()

    Dim response = req.GetResponse().GetResponseStream()

    Dim reader As New StreamReader(response)
    Dim res = reader.ReadToEnd()
    reader.Close()
    response.Close()

    Return res
End Function

【问题讨论】:

    标签: json vb.net api pushwoosh


    【解决方案1】:

    您的网址似乎不完整。会不会是这样?

    Dim myUri As New Uri("https://cp.pushwoosh.com/json/1.3/")
    

    应该是https://cp.pushwoosh.com/json/1.3/createMessage,或者https://cp.pushwoosh.com/json/1.3/registerDevice等。

    【讨论】:

    • 你好。是的,这就是问题所在。感谢您的回复。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-14
    • 2017-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多