本文整理汇总了Python中tumblr.Api.write_link方法的典型用法代码示例。如果您正苦于以下问题:Python Api.write_link方法的具体用法?Python Api.write_link怎么用?Python Api.write_link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tumblr.Api
的用法示例。
在下文中一共展示了Api.write_link方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testWrite
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_link [as 别名]
def testWrite(self):
api = Api(BLOG, USER, PASSWORD)
newpost = api.write_regular('title','body')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
newpost = api.write_link('http://www.google.com')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
newpost = api.write_quote('it was the best of times...')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
newpost = api.write_conversation('me: wow\nyou: double wow!')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
newpost = api.write_video('http://www.youtube.com/watch?v=60og9gwKh1o')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
newpost = api.write_photo('http://www.google.com/intl/en_ALL/images/logo.gif')
post = api.read(newpost['id'])
assert newpost['id'] == post['id']
示例2: Link
# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_link [as 别名]
class Link(gui.CeFrame):
def __init__(self, api):
self.api = api
gui.CeFrame.__init__(self, title="Opentumblr CE")
self.l_link = gui.Label(self, "Add a Link", align = "center")
self.l_name = gui.Label(self, "Name (optional)")
self.tc_name = gui.Edit(self)
self.l_url = gui.Label(self, "URL")
self.tc_url = gui.Edit(self)
self.l_description = gui.Label(self, "Description (optional)")
self.tc_description = gui.Edit(self,multiline = True)
self.b_create = gui.Button(self, "Create Post")
self.b_cancel = gui.Button(self, "Cancel")
self.b_create.bind(clicked = self.OnCreateLink)
self.b_cancel.bind(clicked = self.OnCancel)
self.__set_properties()
self.__do_layout()
def __set_properties(self):
pass
def __do_layout(self):
s_link = gui.VBox(border = (5,5,5,5), spacing = 5)
s_link.add(self.l_link)
s_link.add(self.l_name)
s_link.add(self.tc_name)
s_link.add(self.l_url)
s_link.add(self.tc_url)
s_link.add(self.l_description)
s_link.add(self.tc_description)
s_link.add(self.b_create)
s_link.add(self.b_cancel)
self.sizer = s_link
def OnCreateLink(self, evt):
self.name = self.tc_name.get_text()
self.url = self.tc_url.get_text()
self.description = self.tc_description.get_text()
if self.url:
self.api = Api(self.api.name, self.api.email, self.api.password)
try:
self.post = self.api.write_link(self.name, self.url, self.description)
except:
print "Posteado en el primario"
self.close()
else:
gui.Message.ok(title = 'Warning', caption = 'URL is required')
def OnCancel(self, evt):
self.close()
#if __name__ == '__main__':
# app = gui.Application(Link())
# app.run()