0
该函数将自定义帖子“事件”数据添加到Salesforce数据库中。我已经测试了Wordpress以外的功能,它的工作完美无瑕。当我在Wordpress中通过添加一个新事件来测试它时,没有生成错误,并且数据没有插入到SF数据库中。我也通过打印出$ _POST来测试,并看到数据正在被收集。我怎样才能让这个显示出现一些错误,以便我能够解决这个问题?将wordpress自定义帖子类型数据添加到外部数据库
function add_campaign_to_SF($post_id) {
global $SF_USERNAME;
global $SF_PASSWORD;
if ('event' == $_POST['post-type']) {
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(CD_PLUGIN_PATH . 'Toolkit/soapclient/enterprise.wsdl.xml');
$mySFlogin = $mySforceConnection->login($SF_USERNAME, $SF_PASSWORD);
$sObject = new stdclass();
$sObject->Name = get_the_title($post_id);
$sObject->StartDate = date("Y-m-d", strtotime($_POST["events_startdate"]));
$sObject->EndDate = date("Y-m-d", strtotime($_POST["events_enddate"]));
$sObject->IsActive = '1';
$createResponse = $mySforceConnection->create(array($sObject), 'Campaign');
$ids = array();
foreach ($createResponse as $createResult) {
error_log($createResult);
array_push($ids, $createResult->id);
}
} catch (Exception $e) {
error_log($mySforceConnection->getLastRequest());
error_log($e->faultstring);
die;
}
}
}
add_action('save_post', 'add_campaign_to_SF');
使用此wp_insert_post_data过滤器是一个更好的选择吗? – MG1 2013-04-09 00:19:39
这也得到更新调用...我会设置一个元值,指示您是否已经成功创建了一个对象在SFDC中,ID可能是 – doublesharp 2013-04-09 00:20:52
您可以展示这将如何完成? – MG1 2013-04-09 00:23:01