• J. J. Mark
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Using API Version 33.0. Simple code below results with "Cound not connect to host".

I am reasonably certain this has to do with recent PHP/OpenSSL security fixes, but not sure how to fix it with the Salesforce API. We've fixed this issue in other integrations (e.g. Marketo) by enhancing the SoapClient instantiation with "$options = array('ssl' => array('verify_peer' => false, 'allow_self_signed' => true));" but with the Salesforce API we do not have direct access to the options for the Soap Client instantiation.

Help?

TIA

==============================================

 
require_once ('salesforce2/SforcePartnerClient.php');
require_once ('salesforce2/SforceHeaderOptions.php');

try {
$mySforceConnection = new SforcePartnerClient();    
$mySoapClient = $mySforceConnection->createConnection('partner.wsdl.xml');

$location=$mySforceConnection->getLocation();
$mySforceConnection->setEndpoint($location);
$mylogin = $mySforceConnection->login('user', 'password');

} catch (Exception $e) {    
 echo $mySforceConnection->getLastRequest();    
 echo $e->faultstring;    
}

 

I'm performing a basic related query:

SELECT Id, OpportunityId, Ship_To_Contact__r.Name, Bill_To_Contact__r.Name FROM Quote

I want to be able to retrieve the results, but I'm not sure how to get the related data because it gets placed in nested objects whose index number can change (see examples below).

The PHP below will work properly for Object #1, but will fail for Object #2 and Object #3 because it is referencing their index numbers. But I don't know another way.

I'm hoping that there is a simple approach that I'm missing here...

Thanks!

Mark

 

----

 

//GOAL: tab-delimited data with consistent positions to be mapped to external data source

 

try {

 

$query = 'SELECT Id, OpportunityId, Ship_To_Contact__r.Name, Bill_To_Contact__r.Name FROM Quote';

 

$queryResult = $mySforceConnection->query($query);

 

$records = $queryResult->records;

 

foreach($records as $record) {

$sObject = new SObject($record);

 

//Opp Id - local to table

try {  

echo $sObject->fields->OpportunityId;

}

catch (Exception $ex){

}

echo "\t";

 

 

//Ship-To Related Data

try {

echo $sObject->fields->{1}->fields->Name;

}

catch (Exception $ex){

}

echo "\t";

 

//Bill-To Related Data

try {

echo $sObject->fields->{2}->fields->Name;

}

catch (Exception $ex){

}

echo "\t";

 

echo "\n";

 

}

 

} catch (Exception $ex) {

print_r($ex);

echo $mySforceConnection->getLastRequest();

echo $e->faultstring;

}

 

-----


FIRST OBJECT RETURNED -- Ship-To is nested object #1 and Bill-To is nested object #2


SObject Object
(
[type] => Quote
[fields] => stdClass Object
(
[OpportunityId] => 006i0000009cSbeAAE
[1] => SObject Object
(
[type] => Contact
[fields] => stdClass Object
(
[Name] => Roger Waters
)

)

[2] => SObject Object
(
[type] => Contact
[fields] => stdClass Object
(
[Name] => Syd Barrett
)

)

)

[Id] => 0Q0i0000000FcbZCAS
)


SECOND OBJECT RETURNED -- See how both Ship-To and Bill-To have become attributes

SObject Object
(
[type] => Quote
[fields] => stdClass Object
(
[OpportunityId] => 006i0000009cSbZAAU
[Ship_To_Contact__r] =>
[Bill_To_Contact__r] =>
)

[Id] => 0Q0i0000000FcbACAS
)


THIRD OBJECT RETURNED -- See how the Ship-To is an attribute and the Bill-To is now nested object #1 instead of #2

SObject Object
(
[type] => Quote
[fields] => stdClass Object
(
[OpportunityId] => 006i000000BNAcqAAH
[Ship_To_Contact__r] =>
[1] => SObject Object
(
[type] => Contact
[fields] => stdClass Object
(
[Name] => Jake Test
)

)

)

[Id] => 0Q0i0000000FykgCAC
)

Using API Version 33.0. Simple code below results with "Cound not connect to host".

I am reasonably certain this has to do with recent PHP/OpenSSL security fixes, but not sure how to fix it with the Salesforce API. We've fixed this issue in other integrations (e.g. Marketo) by enhancing the SoapClient instantiation with "$options = array('ssl' => array('verify_peer' => false, 'allow_self_signed' => true));" but with the Salesforce API we do not have direct access to the options for the Soap Client instantiation.

Help?

TIA

==============================================

 
require_once ('salesforce2/SforcePartnerClient.php');
require_once ('salesforce2/SforceHeaderOptions.php');

try {
$mySforceConnection = new SforcePartnerClient();    
$mySoapClient = $mySforceConnection->createConnection('partner.wsdl.xml');

$location=$mySforceConnection->getLocation();
$mySforceConnection->setEndpoint($location);
$mylogin = $mySforceConnection->login('user', 'password');

} catch (Exception $e) {    
 echo $mySforceConnection->getLastRequest();    
 echo $e->faultstring;    
}

 

I have two custom tables:

Location__c (Master)

Trans__c (Detail)

 

When I run this query:

select

Qty__c,

Location__c,

Location__r.Location_Type__c

from Trans__c

 

I get the field name "Location__c" for the third field instead of the value from that field in the parent table.  What am I doing wrong?

 

Thanks!