我正在尝试使用 Twilio 的 API 和vobject发送 vCard 文件(允许您在移动设备上保存联系人) 。
这是我的代码:
import vobject
import requests
from twilio.rest import Client
account_sid = 'MY_SID_HIDDEN'
auth_token = 'AUTH_TOKEN_HIDDEN'
j = vobject.vCard()
j.add('n')
j.n.value = vobject.vcard.Name(family='Harris', given='Jeffrey')
j.add('fn')
j.fn.value = 'Jeffrey Harris'
j.add('email')
j.email.value = 'jeffrey@osafoundation.org'
j.email.type_param = 'Internet'
client = Client(account_sid, auth_token)
client.api.account.messages.create(
to="NUMBER_HIDDEN",
from_="NUMBER_HIDDEN",
body=j
)
当我的设备收到消息时,它看起来像这样:
<VCARD| [<EMAIL{'TYPE': ['Internet']}jeffrey@osafoundation.org>, <FN{}Jeffrey Harris>, <N{} Jeffrey Harris >]>
为什么会这样?