我想为那些点击广告系列中链接的用户提供电子邮件地址。 我正在使用文档中的GET / reports / {campaign_id} / email-activity
https://developer.mailchimp.com/documentation/mailchimp/reference/reports/email-activity/
我了解如何获取电子邮件或活动。但是,如何仅获取单击公司链接的电子邮件?
$curlopt_url = "https://us19.api.mailchimp.com/3.0/reports/4d92ce9489/email-activity?count=400&fields=emails.email_address,emails.activity";
curl_setopt($ch, CURLOPT_URL, $curlopt_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Authorization: Basic '.$auth));
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/3.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 900);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$result = curl_exec($ch);
答案 0 :(得分:1)
您可以使用路线GET /reports/{campaign_id}/click-details
获取有关您的广告系列链接的信息,并返回如下信息:
HTTP/1.1 200 OK
Server: nginx
Content-Type: application/json; charset=utf-8
Content-Length: 1550
Vary: Accept-Encoding
X-Request-Id: 0d2a23c7-b54a-47ca-adc7-95dff2fd4dcc
Link: <https://api.mailchimp.com/schema/3.0/Reports/ClickDetails/Collection.json>; rel="describedBy"
Date: Thu, 17 Sep 2015 14:56:01 GMT
Connection: keep-alive
{
"urls_clicked": [
{
"id": "54debc3673",
"url": "http://inspiration.mailchimp.com?goal=0_57afe96172-42694e9e57-[LIST_EMAIL_ID]&mc_cid=42694e9e57&mc_eid=[UNIQID]",
"total_clicks": 0,
"click_percentage": 0,
"unique_clicks": 0,
"unique_click_percentage": 0,
"last_click": "",
"campaign_id": "42694e9e57",
"_links": [
{
"rel": "parent",
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/click-details",
"method": "GET",
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/ClickDetails/Collection.json"
},
{
"rel": "self",
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/click-details/54debc3673",
"method": "GET",
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/ClickDetails/Instance.json"
},
{
"rel": "members",
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/click-details/54debc3673/members",
"method": "GET",
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/ClickDetails/Members/Collection.json"
},
{
"rel": "campaign",
"href": "https://usX.api.mailchimp.com/3.0/campaigns/42694e9e57",
"method": "GET",
"targetSchema": "https://api.mailchimp.com/schema/3.0/Campaigns/Instance.json"
}
]
}
],
"campaign_id": "42694e9e57",
"_links": [
{
"rel": "parent",
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/",
"method": "GET",
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Instance.json"
},
{
"rel": "self",
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/click-details",
"method": "GET",
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/ClickDetails/Collection.json"
}
],
"total_items": 1
}
确定要在其中链接的特定链接,然后使用路线GET /reports/{campaign_id}/click-details/{link_id}/members
获取单击了链接的联系人,例如:
HTTP/1.1 200 OK
Server: nginx
Content-Type: application/json; charset=utf-8
Content-Length: 498
Vary: Accept-Encoding
X-Request-Id: e9979709-0ce6-4c82-877f-0e77a6f850be
Link: <https://api.mailchimp.com/schema/3.0/Reports/ClickDetails/Members/Collection.json>; rel="describedBy"
Date: Thu, 17 Sep 2015 15:15:45 GMT
Connection: keep-alive
{
"members": [
{
"email_id": "62eeb292278cc15f5817cb78f7790b08",
"email_address": "urist.mcvankab@freddiesjokes.com",
"clicks": 42,
"campaign_id": "42694e9e57",
"url_id": "54debc3673",
"list_id": "4ca5becb8d"
}
],
"campaign_id": "42694e9e57",
"_links": [
{
"rel": "parent",
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/click-details/54debc3673",
"method": "GET",
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/ClickDetails/Instance.json"
},
{
"rel": "self",
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/click-details/54debc3673/members",
"method": "GET",
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/ClickDetails/Members/Collection.json"
}
],
"total_items": 0
}
答案 1 :(得分:-1)
您可以尝试以下操作:
$emailsClicked = array();
foreach ($row in json_decode($result))
{
if ($row->activity->action == 'click')
$emailsClicked[] = $row->email_address;
}
print_r($emailsClicked);
我无法尝试此代码。如果不起作用,请提供var_dump($ result);