我试图使用PHP Api从iconcontact存储联系人。我已经注册了帐户,我正在使用iContact提供的GitHub中的icontacapi .php。
我的源代码看起来像这样l
// Load the iContact library
require_once('ws/iContactApi.php');
// Give the API your information
iContactApi::getInstance()->setConfig(array(
'appId' => 'myappID',
'apiPassword' => 'myuser',
'apiUsername' => 'mypass'
));
// Store the singleton
$oiContact = iContactApi::getInstance();
// Try to make the call(s)
//try {
// are examples on how to call the iContact PHP API class
// Create a contact
var_dump($oiContact->addContact('joe@shmoe.com', null, null, 'Joe', 'Shmoe', null, '123 Somewhere Ln', 'Apt 12', 'Somewhere', 'NW', '12345', '123-456-7890', '123-456-7890', null));
//}
我得到以下错误:
致命错误:未捕获的异常' exception '带有消息'Errors have .已发生,系统无法继续。请使用getErrors()获取详细信息。在C:xampphtdocsclydebutcherws icontacapi .php:482栈跟踪:#0C: xampp 根 clydebutcher ws iContactApi.php (1096):iContactApi->makeCall('/a/', 'get', NULL, 'accounts') #1C: xampp 根 clydebutcher ws iContactApi.php (212):iContactApi -> setAccountId () # 2C: xampp 根 clydebutcher mdl-newsletter-save.php (130):iContactApi->addContact('joe@shmoe.com', NULL, NULL, 'Joe', 'Shmoe',NULL, '123某处L…,"Apt 12","某处","西北","12345",'123-456-7890', '123-456-7890', null) #3C: xampp 根 clydebutcher mdl.php (14):包括(C: xampp 根…)# 4C: xampp 根 clydebutcher index . php (13):include('C:xampphtdocs…')#5 {main}抛出C:xampphtdocsclydebutcherws icontacapi .php on line 482
我做错了什么吗?
您需要使用来自iContact API的getError()方法来查找有关所发生事件的更多信息。
try {
// Give the API your information.
iContactApi::getInstance()->setConfig(array(
'appId' => 'myid',
'apiPassword' => 'mypassword',
'apiUsername' => 'mysecret',
));
// Store the singleton
$oiContact = iContactApi::getInstance();
// Create a contact
var_dump($oiContact->addContact('joe@shmoe.com', null, null, 'Joe', 'Shmoe', null, '123 Somewhere Ln', 'Apt 12', 'Somewhere', 'NW', '12345', '123-456-7890', '123-456-7890', null));
}
catch (Exception $e) {
print_r($oiContact->getErrors();
}