我有点麻烦。我试着发一个帖子,试着按照文档进行操作,但我似乎做不到。在
在github上:https://github.com/trtmn/Python
欢迎拉取请求!
# Getting documentation from :
#https://docs.python.org/2/howto/urllib2.html
import urllib
import urllib2
url = 'https://hooks.slack.com/services/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'
values = {"username": "webhookbot", "text": "This is posted to #general and comes from a bot named webhookbot.", "icon_emoji": ":ghost:"}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
使用httplib作为POST的替代:
*导入httplib
看看这是否有用。在
看起来我需要把它串成JSON(我知道,但不知道怎么做)。感谢Tim G.的帮助。在
功能代码如下:
不确定这是否能解决问题,但如果我在你的url末尾加上一个斜杠,当我执行你的代码时,我确实收到了一个响应。在
url='https://hooks.slack.com/services/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/'
相关问题 更多 >
编程相关推荐