WordPress + Постоянный контакт PHP SDK включает путь

В настоящее время я пытаюсь внедрить постоянный контакт PHP SDK в WordPress сайт. Попросите часть SDK включить некоторые основные файлы PHP, чтобы код электронной почты работал. Если эти файлы не найдены, страница умирает без ошибки PHP. В настоящее время у меня есть папка под названием «src» (не мое соглашение об именах), которая находится в корне темы сайта (/ wp-content / themes / mytheme / src …).

Вот код электронной почты, который вызывает файлы:

<?php
// require the autoloader
require_once(TEMPLATEPATH . '/src/Ctct/autoload.php');

use Ctct\ConstantContact;
use Ctct\Components\Contacts\Contact;
use Ctct\Components\Contacts\ContactList;
use Ctct\Components\Contacts\EmailAddress;
use Ctct\Exceptions\CtctException;

// Enter your Constant Contact APIKEY and ACCESS_TOKEN
define("APIKEY", "XXXXXX");
define("ACCESS_TOKEN", "XXXXXX");

$cc = new ConstantContact(APIKEY);

// attempt to fetch lists in the account, catching any exceptions and printing the errors to screen
try {
$lists = $cc->getLists(ACCESS_TOKEN);
} catch (CtctException $ex) {
foreach ($ex->getErrors() as $error) {
print_r($error);
}
}

// check if the form was submitted
if (isset($_POST['email']) && strlen($_POST['email']) > 1) {
$action = "Getting Contact By Email Address";
try {
// check to see if a contact with the email addess already exists in the account
$response = $cc->getContactByEmail(ACCESS_TOKEN, $_POST['email']);

// create a new contact if one does not exist
if (empty($response->results)) {
$action = "Creating Contact";

$contact = new Contact();
$contact->addEmail($_POST['email']);
$contact->addList($_POST['list']);
$contact->first_name = $_POST['first_name'];
$contact->last_name = $_POST['last_name'];

/*
* The third parameter of addContact defaults to false, but if this were set to true it would tell Constant
* Contact that this action is being performed by the contact themselves, and gives the ability to
* opt contacts back in and trigger Welcome/Change-of-interest emails.
*
* See: http://developer.constantcontact.com/docs/contacts-api/contacts-index.html#opt_in
*/
$returnContact = $cc->addContact(ACCESS_TOKEN, $contact, false);

// update the existing contact if address already existed
} else {
$action = "Updating Contact";

$contact = $response->results[0];
$contact->addList($_POST['list']);
$contact->first_name = $_POST['first_name'];
$contact->last_name = $_POST['last_name'];

/*
* The third parameter of updateContact defaults to false, but if this were set to true it would tell
* Constant Contact that this action is being performed by the contact themselves, and gives the ability to
* opt contacts back in and trigger Welcome/Change-of-interest emails.
*
* See: http://developer.constantcontact.com/docs/contacts-api/contacts-index.html#opt_in
*/
$returnContact = $cc->updateContact(ACCESS_TOKEN, $contact, false);
}

// catch any exceptions thrown during the process and print the errors to screen
} catch (CtctException $ex) {
echo '<span class="label label-important">Error ' . $action . '</span>';
echo '<div class="container alert-error"><pre class="failure-pre">';
print_r($ex->getErrors());
echo '</pre></div>';
die();
}
}
?>

autoload.php доступен там, где он должен быть http://www.thedaileymethod.com/_main_site/wp-content/themes/dailey-method/src/Ctct/autoload.php это то, что я думал, я назвал в файле PHP, но страница продолжает ломаться для меня.

У меня неверный путь require_once?

РЕДАКТИРОВАТЬ:

Когда код for загружен, страница 500 ошибок. Когда я удаляю код формы, эта ошибка исчезает и страница загружается нормально. Ничего, ничего в журнале с точки зрения ошибки PHP.

0

Решение

Удалить заявления с использованием use ключевое слово и изменение

$cc = new ConstantContact(APIKEY);

в

$cc = new \Ctct\ConstantContact(APIKEY);
0

Другие решения

Других решений пока нет …