stathat.com的扭曲包装
txStatHat的Python项目详细描述
用于StatHat的EZ API的Twistedapi包装。
用法很简单:
from twisted.internet import reactor from twisted.internet.defer import inlineCallbacks from txstathat import txStatHat @inlineCallbacks def doSomeStats(): sh = txStatHat('ezKeyOrEmail') yield sh.count('aCounter') # Counts by 1 by default yield sh.count('anotherCounter', 42) yield sh.value('aValue', 0.42) reactor.callLater(1, doSomeStats) reactor.run()
ezKeyOrEmail开头是您的电子邮件地址,但可以是 在帐户设置中更改为更安全的设置。没有这种事 作为密码。
默认情况下,错误会被默默地吞没,因此状态的中断不会导致 意外中断你的服务。同时获取网络异常 作为api错误消息,在实例化时设置ignore_errors=False。 TXStathat公司。只有当你有充分的理由的时候你才应该这样做。
Please note: At the moment, StatHat.com does not report an error when an incorrect EZ API key is submitted. Therefore the above example will work without any effect even if you don’t replace the API key.
stata.com对错误的态度似乎与 TXStathat公司。它们返回一个ok,除非您不正确地使用了api(不要 例如,提供一个api密钥)。区别在于,如果ignore_errors是 保留默认值True,访问api的网络问题将被忽略为 好。
根据pyOpenSSL的可用性,txstathat使用https进行api调用 如果可能的话。虽然攻击者不会对你造成太大的伤害 (s)他劫持了你的api密钥,我强烈建议你安装并使用它。