1
를 메일 침프하는 subscrber를 추가나는이 기능을 쓰기 API v3의에게
public function mailchimp() {
$email = '[email protected]';
$first_name = 'Test';
$last_name = 'Test';
$api_key = 'dfrgergredgdfgdfgdfgdfg-us9'; // YOUR API KEY
// server name followed by a dot.
// We use us13 because us13 is present in API KEY
$server = 'us9.';
$list_id = '718943'; // YOUR LIST ID
$auth = base64_encode('user:'.$api_key);
$data = array(
'apikey' => $api_key,
'email_address' => $email,
'status' => 'subscribed',
'merge_fields' => array(
'FNAME' => $first_name,
'LNAME' => $last_name
)
);
$json_data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://'.$server.'api.mailchimp.com/3.0/lists/'.$list_id.'/members/');
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_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
$result = curl_exec($ch);
$result_obj = json_decode($result);
// printing the result obtained
echo $result_obj->status;
echo '<br>';
echo '<pre>'; print_r($result_obj); echo '</pre>';
}
을하지만 난 (404 오류)이 결과를 가지고 내가 무엇을 잘 모릅니다 내가 틀렸다 여기서
404
stdClass Object
(
[type] => http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/
[title] => Resource Not Found
[status] => 404
[detail] => The requested resource could not be found.
[instance] => 637c9154-9999-48d2-952f-e994b737a9b7
)
여기에 무슨 문제가 있습니까? 404 오류가 발생하는 이유는 무엇입니까? 내 코드에서 오류가 보이지 않습니다. 어떻게이 문제를 해결할 수 있습니까?
나는 Laravel 5.1을 사용합니다. 영어로 죄송합니다!