+ Start a Discussion
nwingnwing 

How do I pass data from a php form using class.http.php to salesforce?

 

I have been tasked with getting this up and running and haven't done anything quite this involved yet.  On the salesforce side in particular  I am not sure what  I need in the http/php class to get the login to function.

 

Any thoughts on where to go from that? 

 

thank you,

 

 

msimondsmsimonds

You need to login to the API using PHP :smileyhappy: ?

 

1) Easy enough!  you can google it or download it from > http://www.mikesimonds.com/attachments/salesforce-php-tutorials/89d1274275000-connecting-php-form-salesforce-phptoolkit-13_1.zip

 

2) then test your login (code originally written by David Claiborne)

 

 

<?php


require_once ('./soapclient/SforcePartnerClient.php');
require_once ('./soapclient/SforceHeaderOptions.php');
// Login to salesforce.com

$login = "you@email.com";
$password = "yourpass";
$key = "your salesforce token";

$password = $password . $key;

$wsdl = "./soapclient/partner.wsdl.xml";

$client = new SforcePartnerClient();
$client->createConnection($wsdl);

try
{
$loginResult = $client->login($login, $password);

if ($loginResult->passwordExpired)
{
$client = null;
}
}
catch (exception $e)
{

$client = null;
echo '<pre>'.print_r($e,true).'</pre>';
}
?>

 

 

4) Make sure that you change the paths in this login script to match your environment

 

5) include this in your script and do a print_r on the $client object/variable

 

6) you should be able to see your login info in the print_r, that will tell you if you are logged in or not. You shoud see something like this:

 

 

 

stdClass Object
(
    [metadataServerUrl] => https://na2-api.salesforce.com/services/Soap/m/19.0/00D300000006AVj
    [passwordExpired] => 
    [sandbox] => 
    [serverUrl] => https://na2-api.salesforce.com/services/Soap/u/19.0/00D300000006AVj
    [sessionId] => 00D300000006AVj!ASAAQAYaLQQo0znAtonSzJ_Z9Q0IjJLNQ88EFsqJmv1AbVyYmQHtY_MZhBUG8Wl3wyH.zrB3WW2aomK9MqgDoHMxRQ0dPuT9
    [userId] => 00540000000oJjiAAE
    [userInfo] => stdClass Object
        (
            [accessibilityMode] => 
            [currencySymbol] => $
            [orgDefaultCurrencyIsoCode] => USD
            [orgDisallowHtmlAttachments] => 
            [orgHasPersonAccounts] => 
            [organizationId] => 00D300000006AVjEAM
            [organizationMultiCurrency] => 
            [organizationName] => Your Company
            [profileId] => 00e30000000mDYzAAM
            [roleId] => 00E40000000nKsUEAU
            [userDefaultCurrencyIsoCode] => 
            [userEmail] => your@email.com
            [userFullName] => Admin User
            [userId] => 00540000000oJjiAAE
            [userLanguage] => en_US
            [userLocale] => en_US
            [userName] => you@email.com
            [userTimeZone] => America/Los_Angeles
            [userType] => Standard
            [userUiSkin] => Theme3
        )

)

 

 

7) that will tell you that you are logged in.

 

 

 

Once you are logged in, you can do what you need to do  like instering the data from your form into an object in Salesforce

 

Check out my link below my sig for some examples!!

 

 

Hope this helps!

 

~Mike