stannp的api包装器,通过web api(如明信片和信件)发送蜗牛邮件的服务。

stannp的Python项目详细描述


AndyPi的Stannp的Python API包装器

什么是斯坦普?

Stannp允许您通过web api发送蜗牛邮件它包括 明信片和信件。有关详细信息,请参见stannp.com。

安装

pip install stannp

示例用法

初始化

导入模块并使用stannp api密钥创建实例

from stannp import StannpClient
STANNP_API_KEY="XXXXXXXXXXXX"
stannpinstance=StannpClient(STANNP_API_KEY)

测试发送明信片并返回json repsonse

# set recipient using a python dictionary
recipient={'title': 'Mr', 'firstname':'Andy', 'lastname':'Pi', 'address1': 'My House', 'address2': 'My Town', 'city':My City', 'postcode': 'Postcode', 'country':'GB'}
# Set the message text
message="Hi Friend,\n\n This is a sample postcard using AndyPi's stannp-api wrapper for python"
# Creates the postcard (where test.jpg is the filename of the front of the card)
card=stannpinstance.send_postcard(size="A6", test=True, recipient=recipient, front="test.jpg", back=None, message=message, signature=None)
# Prints the JSON repsonse from the stannp server, including the URL of a PDF preview
print card

测试发送一封信并从repsonse返回pdf预览url

# set recipient using a python dictionary
recipient={'title': 'Mr', 'firstname':'Andy', 'lastname':'Pi', 'address1': 'My House', 'address2': 'My Town', 'city':My City', 'postcode': 'Postcode', 'country':'GB'}
# Set the message text to be a PDF named test.pdf (note the first page will have the recipients address)
letter=stannpinstance.send_letter(test=True, template=None, recipient=recipient, background=None, pages="test.pdf", pdforhtml="pdf")
# print the URL of the preview PDF
print letter['data']['pdf']

其他

请参阅stannp.py中的注释/doctrings以了解如何 使用所有功能。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何使用java向dropup html/css添加项目   如何从java中的向量向量打印   Java Maven库项目模板   java使用atmosphere api还是直接使用grizzly?   java JComponent仅部分显示   如何将动态值传递给自定义注释,以从Java数据进行映射。性质   java破解已实现方法的返回类型的最佳方法?   java Netbeans在JFrame Gui布局中覆盖图像   spring java仅向登录用户显示注销按钮   java如何对com进行身份验证。谷歌。云bigquery。带有服务帐户的BigQuery`   java禁止空字符串参数和抛出RuntimeException以阻止方法继续的利弊   java分析项目中的所有JAR以获取版本和许可证信息   Java,数据库为什么要分配一个新对象,而我们可以直接将它放入数据库