API
API整合-Webhook篇

继续回答前面『API整合-入门篇 』这个问题:

Q4:需要发给会员的邮件发送状态,以及邮件打开,点击等会员行为数据,还有会员客户端,访问地理位置等信息,这些数据要怎么能够获得?

我们先解释一下 Webhook:

Webhook是一种消息订阅异步接口实现方式,它能够将用户订阅消息数据及时的传输到用户指定的位置(URL)。而灵动营销平台也提供这种接口,能够将用户订阅的邮件发送状态,用户的会员打开邮件,点击里面链接,更新会员信息等行为事件信息数据及时的传回用户业务系统。

下面灵动营销平台Webhook设置界面,订阅地址就是用户接送订阅数据的地址。

订阅会员行为

那么订阅数据是个什么样子,我们来看看下面这段文本,如果稍有点程序猿背景的同学,一眼就会看出。嗯,这是个JSON格式的数据,无论是对人还是对系统都比较容易理解。

//备注:下面示例数据在已经做了混淆:)
{
    "delivered": [
        {
            "id": 2201602002317593, 
            "campaign": "大麦网温馨提示:您关注的演出内容有更新", 
            "email": "hg007@example.com", 
            "status": "bounce:hard", 
            "dsn": "Action: failed | Status: 5.1.2 (bad destination system: no such domain)", 
            "updated": "2014-02-20 18:08:05", 
            "createdAt": "2014-02-20 18:08:04", 
            "scheduleId": 17436, 
            "messageId": 12399, 
            "contactId": 19016004
        }, 
        {
            "id": 22201606019253710, 
            "campaign": "大麦网温馨提示:您关注的演出内容有更新", 
            "uid": "GFpCmAhnXpPoXqXLH2BY", 
            "email": " xiaorong@example.com ", 
            "status": "success", 
            "dsn": "smtp;250 ok: Message 1758717523 accepted", 
            "updated": "2014-06-27 15:03:04", 
            "createdAt": "2014-06-27 15:02:20", 
            "scheduleId": 121830, 
            "messageId": 162084, 
            "contactId": 43001513
        }
    ], 
    "clicks": [
        {
            "id": 22201603016582230, 
            "campaign": "大麦网温馨提示:您关注的演出内容有更新", 
            "subject": "大麦网温馨提示:您关注的演出内容有更新", 
            "uid": "GFpCmAhnXpPoXqXLH2BY", 
            "email": "someone@example.com", 
            "ip": "119.255.75.126", 
            "location": "中国/河北/廊坊", 
            "longitude": 116.7139, 
            "latitude": 39.5292, 
            "device": "", 
            "platform": "Windows 7", 
            "client": "Chrome", 
            "url": "http://item.damai.cn/78982.html", 
            "createdAt": "2014-02-20 18:08:05"
        }, 
        {
            "id": 22201603026582230, 
            "campaign": "大麦网温馨提示:您关注的演出内容有更新", 
            "subject": "大麦网温馨提示:您关注的演出内容有更新", 
            "uid": "GFpCmAhnXpPoXqXLH2BY", 
            "email": "someone@example.com", 
            "ip": "119.255.75.126", 
            "location": "中国/河北/廊坊", 
            "longitude": 116.7139, 
            "latitude": 39.5292, 
            "device": "", 
            "platform": "Windows 7", 
            "client": "Chrome", 
            "url": "#退订", 
            "createdAt": "2014-02-20 18:08:05"
        }
    ], 
    "opens": [
        {
            "id": 222016111000001234, 
            "campaign": "大麦网温馨提示:您关注的演出内容有更新",
            "subject": "大麦网温馨提示:您关注的演出内容有更新", 
            "uid": "GFpCmAhnXpPoXqXLH2BY", 
            "email": "someone@example.com", 
            "ip": "119.255.75.126", 
            "location": "中国/河北/廊坊", 
            "longitude": 116.7139, 
            "latitude": 39.5292, 
            "device": "", 
            "platform": "Windows 7", 
            "client": "Chrome", 
            "createdAt": "2014-02-20 18:08:05"
        }
    ], 
    "unsubscriptions": [
        {
            "id": 222019111000001234, 
            "campaign": "大麦网温馨提示:您关注的演出内容有更新",
            "subject": "大麦网温馨提示:您关注的演出内容有更新", 
            "uid": "GFpCmAhnXpPoXqXLH2BY", 
            "email": "example@abc.com", 
            "ip": "119.255.75.126", 
            "location": "中国/河北/廊坊", 
            "longitude": 116.7139, 
            "latitude": 39.5292, 
            "device": "", 
            "platform": "Windows 7", 
            "client": "Chrome", 
            "source": "esp", 
            "content": "I do not want to receive these emails anymore .", 
            "createdAt": "2014-02-20 18:08:05"
        }
    ], 
    "complaints": [
        {
            "id": 222019111000005678, 
            "campaign": "KiKUU Order Shipped Reminder",
            "subject": "KiKUU Order Shipped Reminder", 
            "uid": "65655dnvdte0", 
            "email": "one@someone.com", 
            "ip": "117.136.31.250", 
            "location": "中国/广东省/广州市", 
            "longitude": 116.7139, 
            "latitude": 39.5292, 
            "device": "", 
            "platform": "Windows 7", 
            "client": "Chrome", 
            "source": "esp", 
            "content": "在沒有任何解釋及通知的情況下, 退還按金時直接扣了大約27英鎊。在現場交還汽車時並沒有指出任何問題需要作出賠償,現在卻無理地少退還了按金。請協助跟進。", 
            "createdAt": "2014-02-20 18:08:05"
        }
    ]
}

如需了解更多关于API详细资料,请访问我们官网资源中心的『开发者