我是salesforce和php的新手,基本上我试图执行查询,但是
<?php
define("USERNAME", "myMail");
define("PASSWORD", "mypass");
define("SECURITY_TOKEN", "myToken");
require_once ('soapclient/SforcePartnerClient.php');
$mySforceConnection = new SforcePartnerClient();
$mySforceConnection->createConnection("wsdl.jsp.xml");
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
$query = "SELECT email__c FROM user__c";
$response = $mySforceConnection->query($query);
$queryResult = new QueryResult($response);
?>
但错误:
Fatal error: Uncaught SoapFault exception: [soapenv:Client] Element {}item invalid at this location in /Library/WebServer/Documents/force/soapclient/SforceBaseClient.php:797 Stack trace: #0 /Library/WebServer/Documents/force/soapclient/SforceBaseClient.php(797): SoapClient->__call('query', Array) #1 /Library/WebServer/Documents/force/soapclient/SforceBaseClient.php(797): SforceSoapClient->query(Array) #2 /Library/WebServer/Documents/force/dummy.php(18): SforceBaseClient->query('SELECT email__c...') #3 {main} thrown in /Library/WebServer/Documents/force/soapclient/SforceBaseClient.php on line 797
我不确定我做错了什么。 基本上,我使用工作台SOQL Salesforce,并且查询效果很好。 怎么了? 先谢谢
答案 0 :(得分:0)
看起来您的Sales Force查询应该运行良好 - 但是我不熟悉&#34; QueryResult&#34;函数,也许尝试转储该行,看看它是否有效。这可能只针对一个结果,基本上我们通常只是迭代这样的记录:
// Iterate through SF records
foreach ($response->records as $record) {
//do something with $record here.
print_r($record);
}