Technology Cares

Not Just another weblog

Posts Tagged ‘Force.com’

Import Salesforce data into your MySQL

Posted by Manish on April 16, 2009

The following script is the simple example to understand the process of importing the data from your Salesforce object to the MySQL database:


<?php
ini_set("soap.wsdl_cache_enabled", "0");
define(BASEDIR, 'lib/phptoolkit/soapclient/');
require_once (BASEDIR.'SforcePartnerClient.php');
require_once (BASEDIR.'SforceHeaderOptions.php');
require_once ('adodb/adodb.inc.php');
$db = NewADOConnection('mysql');
$db->Connect("localhost", "Username", "password", "TargetDatabaseName");
$wsdl = BASEDIR.'partner.wsdl.xml';
$userName = "user@somemail.sth";
$password = "passwordsecuritycode";
$client = new SforcePartnerClient();
$client->createConnection($wsdl);
$loginResult = $client->login($userName, $password);
$query = "Select Id,Name FROM Organization";
$response = $client->query($query);
echo '<p>Importing organizations From Salesforce...</p>';
foreach ($response->records as $r)
{
$pass_this['Id'] = $r->Id;
$pass_this['Name'] = addslashes($r->fields->Name);
$sql = $db->execute("INSERT INTO sforce_organization (id,name)
VALUES ('{$pass_this['Id']}','{$pass_this['Name']}' )");
}
echo '<p>Importing organizations From Salesforce Completed.</p>';
?>

Things to remember here are:
1. Configuring PHP

  • Search for the string “extension_dir” in php.ini. Uncomment it and set it equal to ext directory.
  • Turn on the required extensions “extension=php_curl.dll”, “extension=php_soap.dll”, “extension=php_openssl.dll” by uncommenting them
  • Install SSL Library files by copying the SSL library files from the PHP installation directory to your Windows system directory. The two files are libeay32.dll and ssleay32.dll.
  • 2. There is option of Parter WSDL and Enterprise WSDL to be used. I’ve used the Partner WSDL as it supports for the applications that are metadata driven.
    See here for more about these WSDL http://www.salesforce.com/us/developer/docs/sforce70/wwhelp/wwhimpl/common/html/wwhelp.htm?context=sforceAPI_WWHelp&file=sforce_API_partner_intro.html

    Posted in Uncategorized | Tagged: , , , | Leave a Comment »

    Installing Force.com IDE into Eclipse 3.3.x

    Posted by Manish on January 5, 2009

    To install the Force.com IDE into Eclipse 3.3.x, follow these instructions:

    1. Launch Eclipse, and then click Help > Software Updates > Find and Install.
    2. Select “Search for new features to install” and click “Next”.
    3. Add the Force.com IDE Remote Site:
    3.1 Click “New Remote Site”. The New Update Site dialog opens.
    3.2 Set the Name to “Force.com IDE” and the URL to “http://www.adnsandbox.com/tools/ide/install/&#8221;, then click OK.
    3.3 Select “Europa Discovery Site” and “Automatically select mirrors”, then click “Finish”. Eclipse will search the selected sites for the required plugins.
    4. When the Updates dialog is displayed, select “Force.com IDE” and, under Europa Discovery Site > Web and JEE Development, select “Web Standard Tools (WST) Project”. Also click “Select Required” to ensure any dependencies are downloaded.
    5. Click “Next”, then accept the terms and click “Next” again, then click “Finish”. Eclipse will download and install the selected features, including the Force.com IDE. When installation is complete, Eclipse will prompt you to restart, click “OK”. If it’s showing an error in red saying that it needs other plug-ins, click “select required” and wait for it to choose the other required plugins.
    6. Once Eclipse reopens, select Window > Open Perspective > Other and select “Force.com”, then click “OK”.

    Posted in Uncategorized | Tagged: , | Leave a Comment »