试图获取非对象的属性
我正在使用 Soapclient 将一些数据从 php 插入到名为 Application__c 的 salesforce 对象中。连接成功后,我编写了以下代码,
$applications = array();
$updateFields = array();
if($_POST['savingsAccountBankName'] != ''){
$updateFields['savings_account_bank_name__c']= $_POST['savingsAccountBankName'];
}
if($_POST['AutoMake'] != ''){
$updateFields['Auto_make__c']= $_POST['AutoMake'];
}
if($_POST['AutoLicense'] != ''){
$updateFields['Auto_license__c']= $_POST['AutoLicense'];
}
$sObject = new sObject();
$sObject->type = 'Application__c';
$sObject->fields = $updateFields;
array_push($applications, $sObject);
try {
$results = $sforceClient->create($applications,'Application__c');
foreach ($results as $result)
{
$errMessage = $result->errors->message;
echo $errMessage;
}
} catch (Exception $e) {
echo 'Salesforce Upsert Error. Please try again later.';
echo '<pre>';
print_r($e);
echo '</pre>';
}
我在“$errMessage = $result->errors->message;”行收到错误“尝试获取非对象的属性”。问题是什么?
谢谢
i am inserting some data to an salesforce object named as Application__c from php using Soapclient. After connection successfull, i have written following code
$applications = array();
$updateFields = array();
if($_POST['savingsAccountBankName'] != ''){
$updateFields['savings_account_bank_name__c']= $_POST['savingsAccountBankName'];
}
if($_POST['AutoMake'] != ''){
$updateFields['Auto_make__c']= $_POST['AutoMake'];
}
if($_POST['AutoLicense'] != ''){
$updateFields['Auto_license__c']= $_POST['AutoLicense'];
}
$sObject = new sObject();
$sObject->type = 'Application__c';
$sObject->fields = $updateFields;
array_push($applications, $sObject);
try {
$results = $sforceClient->create($applications,'Application__c');
foreach ($results as $result)
{
$errMessage = $result->errors->message;
echo $errMessage;
}
} catch (Exception $e) {
echo 'Salesforce Upsert Error. Please try again later.';
echo '<pre>';
print_r($e);
echo '</pre>';
}
i am getting error "Trying to get property of non-object" at line "$errMessage = $result->errors->message;". What is the problem?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请注意 $result 是一个数组..
试试这个:
Be aware that $result is an array..
Try this :
这意味着无论 $results 包含什么,它都不是一个对象。尝试对变量 $results 执行 var_dump() 并查看其中实际内容。然后就可以正确引用了。
This means that whatever $results contains, it is not an object. Try doing a var_dump() on the variable $results and see what is actually in there. Then you can properly reference it.