当前位置: 首页>>代码示例>>Python>>正文


Python Api.write_photo方法代码示例

本文整理汇总了Python中tumblr.Api.write_photo方法的典型用法代码示例。如果您正苦于以下问题:Python Api.write_photo方法的具体用法?Python Api.write_photo怎么用?Python Api.write_photo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tumblr.Api的用法示例。


在下文中一共展示了Api.write_photo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testWrite

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_photo [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']
开发者ID:mdocode,项目名称:hangTumblr,代码行数:28,代码来源:tumblr-test.py

示例2: main

# 需要导入模块: from tumblr import Api [as 别名]
# 或者: from tumblr.Api import write_photo [as 别名]
def main():
	if len(sys.argv) != 2:
		print "Usage: ./totumblr.py <photofile>"
		sys.exit(-1)

	photo_filename = sys.argv[1]
	parts = photo_filename.split('.')
	file_extension = parts[1]


	ftp = FTP('www.fakemachine.com')
	ftp.login('[email protected]','password')
	ftp.cwd('/domains/fakemachine.com/html/tumblrimages/')
	text = ftp.retrlines('list')


	m = re.search('\d+ matches', text)
	match = m.group(0)
	parts = match.split(' ')
	file_number = int(parts[0]) + 1

	remote_filename = "%d.%s" % (file_number,file_extension)
	fp = open(photo_filename,'rb')
	ftp.storbinary('STOR %s' % remote_filename, fp) # Send the file

	fp.close()
	ftp.quit()

	image_url = "http://www.fakemachine.com/tumblrimages/%s" % remote_filename
	api = Api(BLOG,USER,PASSWORD)
	post = api.write_photo(source=image_url)
	print "Published: ", post['url']
开发者ID:candersonmiller,项目名称:recreational,代码行数:34,代码来源:totumblr.py


注:本文中的tumblr.Api.write_photo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。