我试图编写一个简单的常量联系人脚本来添加和更新电子邮件。脚本很简单,应该可以顺利运行。但是当我开始包括' src / Ctct / autoload.php'页面只返回空白。我尝试在另一台服务器上运行它,它的工作原理。但在我的工作服务器上,它返回空白。它使用CTCT的OAuth身份验证。我认为它是服务器中的一个设置,但我无法控制服务器,任何更改都需要转发给管理员,我只是不知道我需要改变什么。
以下是代码:
require "Scripts/ConstantContact/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;
define("APIKEY", "*** Censored Media (18+ only) ***");
define("ACCESS_TOKEN", "*** Censored Media (18+ only) ***");
$cc = new ConstantContact(APIKEY);
// attempt to fetch lists in the account, catching any exceptions and printing the errors to screen
$lists = $cc->getLists(ACCESS_TOKEN);
$action = "Getting Contact By Email Address";
$Email = "asdf@asdf.com";
$FirstName = "Asdf";
$LastName = "Ghjk";
// check to see if a contact with the email addess already exists in the account
$response = $cc->getContactByEmail(ACCESS_TOKEN, $Email);
// create a new contact if one does not exist
if (empty($response->results)) {
$action = "Creating Contact";
$contact = new Contact();
$contact->addEmail($Email);
$contact->addList('1');
$contact->first_name = $FirstName;
$contact->last_name = $LastName;
$returnContact = $cc->addContact(ACCESS_TOKEN, $contact);
// update the existing contact if address already existed
} else {
$action = "Updating Contact";
$contact = $response->results[0];
$contact->addList('1');
$contact->first_name = $FirstName;
$contact->last_name = $LastName;
$returnContact = $cc->updateContact(ACCESS_TOKEN, $contact);
}
// catch any exceptions thrown during the process and print the errors to screen
if (isset($returnContact)) {
echo '<div class="container alert-success"><pre class="success-pre">';
print_r($returnContact);
echo '</pre></div>';
}
print '<p>'.$action.'</p>';
同样,这适用于我尝试的另一台服务器,但不能在我的工作服务器上运行。
任何帮助都将不胜感激。
谢谢!
答案 0 :(得分:1)
您是否在其他服务器上运行PHP 5.3或更高版本?此外,域名也发生了变化,如果是这样,可能会抛出一个异常导致空白页面,因为您的API密钥是特定于域的。随意给我发一封电子邮件,我很乐意帮你解决这个问题 - mstowe [at] constantcontact.com
-Mike