在wordpress中,我试图将包含在每个帖子中作为自定义字段(称为customer_email)值的特定电子邮件发布到mailchimp自动化。
下面是我的代码,它不起作用
function email_on_publish( $postid ) {
$api_key = API-KEY;
$workflow_id = WORKFLOW-ID;
$email_id = EMAIL-ID;
$email = get_post_meta( get_the_ID(), 'customer_email', true );
$args = array(
'method' => 'POST',
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( 'user:'. $api_key )
),
'body' => json_encode(array(
'email_address' => $email
))
);
$response = wp_remote_post( 'https://' . substr($api_key,strpos($api_key,'-')+1) . '.api.mailchimp.com/3.0/automations/' . $workflow_id . '/emails/' . $email_id . '/queue/' . md5(strtolower($email)), $args );
$body = json_decode( $response['body'] );
}
add_action( 'pending_to_publish', 'email_on_publish' );
add_action( 'draft_to_publish', 'email_on_publish' );
答案 0 :(得分:0)
更新:此问题已解决。有两个问题在手。
谢谢你自己弄清楚!