나는 다음과 같은 코드를 가지고 : 나는 기존 목록의 이름과 내가 원하는 이메일 주소의 배열을 addEmailsToRecipientList을 통과하면PHP- 오류를 반환 500
static function getContext($data) {
// use key 'http' even if you send the request to https://...
$options = array (
'http' => array (
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query ($data)
)
);
return stream_context_create ($options);
}
static function addEmailsToRecipientList($name, $emails) {
$url = 'https://sendgrid.com/api/newsletter/lists/email/add.json';
$temp = array();
foreach($emails as $email){
$temp[] = array('email' => $email, 'name' => 'unknown');
}
$data = array (
'list' => $name,
'data' => json_encode($temp),
'api_user' => $api_user_name,
'api_key' => $api_password
);
$context = SendGridAPI::getContext ($data);
return file_get_contents ($url, false, $context);
}
을 그것에 추가하면 오류 500 (내부 서버 오류)이 발생합니다.
하나의 이메일 ($ temp = array ('email'=> $ email, 'name'=> 'unknown'))을 추가하면 정상적으로 작동합니다. 내가 뭘 잘못하고 있니?
고맙습니다.
500 내부 서버 오류 (또는 빈 페이지)는 스크립트에 오류가 발생했지만 오류 메시지를 표시하도록 PHP를 구성하지 않았 음을 의미합니다. 그것은 당신이 더 나아 가기 전에 고칠 필요가있는 것입니다; 오류 메시지의 도움없이 코딩하는 것은 불가능합니다. 여기에 [간단한 설명] (http://stackoverflow.com/a/5680885/13508)이 있습니다. –
API 문서에 "수신자 목록에 하나 이상의 이메일 추가"여러 이메일을 추가하는 것이 지원되지 않을 수 있습니까? http://community.sendgrid.com/sendgrid/topics/when_adding_recipients_i_get_a_database_error_has_occurred – YOKA
정확한 세부 정보가 포함 된 오류 메시지가 표시되지 않으므로 아무 것도 표시되지 않습니다. –