• adi0908
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Hello, I'm trying the simple query from the docu.

using the actual  version of php toolkit.

only to try out Enterprise wsdl (works fine) and Partner wsdl on the other side.

partner wsdl doesn't give me the expected results.

I only see the id of the contact, and the other fields are combined in any- field.

I want to give out the Firstname, Lastname and so on.

here is the code:

<?php
session_start();
require_once ('soapclient/SforcePartnerClient.php');
require_once ('soapclient/SforceHeaderOptions.php');
//require_once ('soapclient/SforceEnterpriseClient.php');
define ("USERNAME", "myuser@blabla.de");
define("PASSWORD", "mypw");
define("SECURITY_TOKEN", "mytoken");

try {
    $mySforceConnection = new SforcePartnerClient();
    $mySforceConnection->createConnection("soapclient/partner.wsdl.xml");
    if (isset($_SESSION['partnerSessionId'])) {
        $location = $_SESSION['partnerLocation'];
        $sessionId = $_SESSION['partnerSessionId'];
        $mySforceConnection->setEndpoint($location);
        $mySforceConnection->setSessionHeader($sessionId);
        echo "Used session ID for partner<br/><br/>\n";
    } else {
        $mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);

        $_SESSION['partnerLocation'] = $mySforceConnection->getLocation();
        $_SESSION['partnerSessionId'] = $mySforceConnection->getSessionId();

        echo "Logged in with partner<br/><br/>\n";
    }
    $query = "SELECT Id, FirstName, LastName, Phone from Contact";
    $response = $mySforceConnection->query($query);
    $queryResult = new QueryResult($response);
    foreach ($queryResult->records as $record) {
            print_r($record);

            echo $record->Id . ": " . $record->fields->FirstName . " "
            . $record->fields->LastName . " " . $record->fields->Phone . "<br/>\n";            
    }
} catch (Exception $e) {
    echo "Exception ".$e->faultstring."<br/><br/>\n";
    echo "Last Request:<br/><br/>\n";
    echo $mySforceConnection->getLastRequestHeaders();
    echo "<br/><br/>\n";
    echo $mySforceConnection->getLastRequest();
    echo "<br/><br/>\n";
    echo "Last Response:<br/><br/>\n";
    echo $mySforceConnection->getLastResponseHeaders();
    echo "<br/><br/>\n";
    echo $mySforceConnection->getLastResponse();
}
?>

 

 

the doc says, that it works with ...

$record->fields->FirstName

 

but this works not in my case.

 

may be a simple beginner mistake - can you help me?

 

thanks a lot,

 

Adi

 

Hi everybody,

 

I'am a complete newbie to salesforce and I want to upload a pdf-file to salesforce as a account "notes&attachment".

 

the account id, the uploaded file refers to, is part of the filename.

 

is there a way to do this with php and rest api ? If so, could somebody show me a sample code, using php and rest api ?

 

 

 

Thanks a lot, helping me.

Hello, I'm trying the simple query from the docu.

using the actual  version of php toolkit.

only to try out Enterprise wsdl (works fine) and Partner wsdl on the other side.

partner wsdl doesn't give me the expected results.

I only see the id of the contact, and the other fields are combined in any- field.

I want to give out the Firstname, Lastname and so on.

here is the code:

<?php
session_start();
require_once ('soapclient/SforcePartnerClient.php');
require_once ('soapclient/SforceHeaderOptions.php');
//require_once ('soapclient/SforceEnterpriseClient.php');
define ("USERNAME", "myuser@blabla.de");
define("PASSWORD", "mypw");
define("SECURITY_TOKEN", "mytoken");

try {
    $mySforceConnection = new SforcePartnerClient();
    $mySforceConnection->createConnection("soapclient/partner.wsdl.xml");
    if (isset($_SESSION['partnerSessionId'])) {
        $location = $_SESSION['partnerLocation'];
        $sessionId = $_SESSION['partnerSessionId'];
        $mySforceConnection->setEndpoint($location);
        $mySforceConnection->setSessionHeader($sessionId);
        echo "Used session ID for partner<br/><br/>\n";
    } else {
        $mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);

        $_SESSION['partnerLocation'] = $mySforceConnection->getLocation();
        $_SESSION['partnerSessionId'] = $mySforceConnection->getSessionId();

        echo "Logged in with partner<br/><br/>\n";
    }
    $query = "SELECT Id, FirstName, LastName, Phone from Contact";
    $response = $mySforceConnection->query($query);
    $queryResult = new QueryResult($response);
    foreach ($queryResult->records as $record) {
            print_r($record);

            echo $record->Id . ": " . $record->fields->FirstName . " "
            . $record->fields->LastName . " " . $record->fields->Phone . "<br/>\n";            
    }
} catch (Exception $e) {
    echo "Exception ".$e->faultstring."<br/><br/>\n";
    echo "Last Request:<br/><br/>\n";
    echo $mySforceConnection->getLastRequestHeaders();
    echo "<br/><br/>\n";
    echo $mySforceConnection->getLastRequest();
    echo "<br/><br/>\n";
    echo "Last Response:<br/><br/>\n";
    echo $mySforceConnection->getLastResponseHeaders();
    echo "<br/><br/>\n";
    echo $mySforceConnection->getLastResponse();
}
?>

 

 

the doc says, that it works with ...

$record->fields->FirstName

 

but this works not in my case.

 

may be a simple beginner mistake - can you help me?

 

thanks a lot,

 

Adi