Ich habe diese Funktion verwendet, um die Details einer bestimmten Kampagne mit Mailchimp API v3.0 abzurufen.Anzeigen der Betreffzeile der Kampagne mit mailchimp API v3.0
function mc_insert_campaign($email, $apikey, $server) {
$apiKey = 'xxxxxxxxxxxxmyAPI';
$camp_id = '1753ef2cce';
$auth = base64_encode('user:'. $apikey);
$data = array(
'apikey' => $apikey,
'id' => $camp_id
);
$json_data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://'.$server.'.api.mailchimp.com/3.0/campaigns/'. $camp_id);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Authorization: Basic '. $auth));
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
$result = curl_exec($ch);
// if ($debug) {
// var_dump($result);
// }
$json = json_decode($result);
$camp_type = $json->{'type'};
echo $camp_type;
}
Bis jetzt funktioniert es ok für mich, da ich den Kampagnentyp nehme. Aber ich muss auch die Betreffzeile extrahieren.
Wie ich in MC-API-Dokumentation die Json Antwort lesen sieht es so aus:
{
"id": "42694e9e57",
"type": "regular",
"create_time": "2015-09-15T14:40:36+00:00",
"archive_url": ".....",
"status": "save",
"emails_sent": 0,
"send_time": "",
"content_type": "template",
"recipients": {
"list_id": "57afe96172",
"segment_text": ""
},
"settings": {
"subject_line": "I have a rice crispy treat watermelon farm.",
"title": "Freddie's Jokes Vol. 1",
"from_name": "Freddie",
"reply_to": "[email protected]",
"use_conversation": false,
"to_name": "",
"folder_id": 0,
"authenticate": true,
"auto_footer": false,
"inline_css": false,
"auto_tweet": false,
"fb_comments": false,
"timewarp": false,
"template_id": 100,
"drag_and_drop": true
}, .........
Ich habe versucht, so etwas wie
$camp_type = $json->{'settings'}{'type'};
aber es hat nicht funktioniert. Was mache ich falsch? Vielen Dank im Voraus ..