Push API中的Channel和Signature是什么?

时间:2016-08-10 18:49:05

标签: pubnub

在参考HTTP REST Push API时,我的假设是我可以用我的某个pubnub应用程序中的数据替换“发布测试”URL(http://pubsub.pubnub.com/publish/demo/demo/0/hello_world/0/%22Hello%20World%22)并将其放入浏览器中。我做了这个,用我的pub和子键替换了“demo”字符串。我收到了一个带有唯一ID的“已发送”的JSON响应。但是,当我查看我在帐户中使用的演示密钥集时,它会显示“0消息”。

  1. 什么是频道和签名(上面的URL中的0)?我需要它们吗?我从哪里得到它们?
  2. 上述测试会在我的演示密钥中注册一个消息计数吗?
  3. enter image description here

1 个答案:

答案 0 :(得分:2)

PubNub管理信息中心使用情况

使用情况每24小时计算一次,并在太平洋时间早上9点左右发布到您的帐户。

PubNub REST API

对于发布REST调用,0参数为signaturecallback(不是channel,如您所示 - 假设您的意思是callback, ):

http://pubsub.pubnub.com/publish
/pub-key
/sub-key
/signature
/channel
/callback
/message

提供的示例(显示给其他人):

http://pubsub.pubnub.com
/publish
/demo
/demo
/0
/hello_world
/0
/%22Hello%20World%22

signature(第一个0)已在3年前弃用,因此应始终为0callback只是应该为publish响应调用的函数的名称。 PubNub SDK使用此功能,因此0适用于大多数非SDK用例。

以下是更详细的publish REST文档:

https://pubsub.pubnub.com/publish/{pub_key}/{sub_key}/0/{channel}/{callback}/{payload}{?store}

URI参数

Name          Type          Required          Description
pub_key       string        Yes               your publish key
sub_key       string        Yes               your subscribe key
channel       string        Yes               channel to publish the message to
callback      string        Yes               response will be wrapped in JSONP function, 0 for no JSONP
payload       string        Yes               message to send (url-encoded JSON)
store         number        No                overrides default account configuration on message saving. store: 1, do not store: 0
auth          string        No                if the channel is protected by Access Manager (requires a permissions to be granted), auth must be passed with an auth-key which is authorized to write to the channel.