• CarstenHar
  • NEWBIE
  • 0 Points
  • Member since 2009

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

InTradeSys Limited is proud to announce the "SalesForce.com Accelerator Toolkit for PHP" 

 

The SalesForce.com Accelerator Toolkit for PHP (SFatp) is the next step in programming the Sales-Force.com API with PHP. The toolkit gives you a kind of SDK for usage in PHP application on the webserver and/or the command line.

  

Once programmers are starting in using any Webservice with PHP a kind of desperation is not fare away. Although PHP4 and PHP5 are aware of calling SOAP styled webservices the process is loosely integrated to object-oriented paradigms used in PHP. Typically NuSOAP or PEAR-SOAP was used under PHP4, whereas PHP5 is bringing a native extension. Traditionally PHP is loosely typed and using webservices under PHP makes things even worse. Programmers have to use objects of the type “stdClass” and need to handle plain arrays. State of the art IDEs are able to help a programmer with auto-completion and many other utilities to write error prone code and reduce the number of typos. Using SOAP under PHP normally results in “trial and error”-code; doing calls, using series of print_r, and copy/paste found attributes or array-keys to the code.

 

When InTradeSys started in using SOAP webservices we found that other languages were much more ma-ture here. Typically a tool is used that generates a client proxy out of the WSDL of a webservice and inte-grates the resulting library. So we builded such a tool for ourself and used it in many SOAP integration pro-jects. Nevertheless the resulting library not only includes generated PHP-classes but also a fully featured SOAP-client. Basically the full pipeline of SOAP processing (serialization, transport and deserilization) is done with custom PHP code. This gives us a way to present many interesting features that finally will allow us to have a very efficient and “nice” code.

 

The toolkit is offered in various "edtions" basically representing ALL SalesForce.com API, so Partner, Enterprise, Metadata and Apex! All libraries are under LGPL so can be used in commercial applications with no pain.

 

As an extra service customized version can be provided for enterprise.wsdl files on demand. So custom-fields and custom-object can be cleanly integrated to the proxy-code.  

 

Following a short example code for the SFatp usage: 

 


require_once '../lib/its-test-enterprise/sForce_ServiceProxyEnterprise.php';

require_once '../lib/its-test-enterprise/GetUpdated.php';
require_once '../lib/its-test-enterprise/GetUpdatedResponse.php';

require_once '../lib/its-test-enterprise/Retrieve.php';
require_once '../lib/its-test-enterprise/RetrieveResponse.php';

// using auto-initiate session here, so we will not get any logging for the login !
$sf = new sForce_ServiceProxyEnterprise('config/sf.config.php');


$sObjectType = 'Account';
$fieldList = 'Id, AccountNumber, Name, Description, Website';

$req = new GetUpdated();
$req->setSObjectType($sObjectType);

$now = gmdate('U');

// getting data from the last 24 hours !
$end = date('Y-m-d\TH:i:s\Z', $now);
$start = date('Y-m-d\TH:i:s\Z', $now - 60 * 60 * 24);

$req->setStartDate($start);
$req->setEndDate($end);

$res = $sf->GetUpdated($req);
$result = $res->getResult();

$reqRetrieve = new Retrieve();
$reqRetrieve->setSObjectType($sObjectType);
$reqRetrieve->setFieldList($fieldList);
// be aware that the limit for retrieve is 2000 ! Whereas GetUpdated might
// return up to 200,000 ids. So in a production scenario the list has to be
// splitted if operating on large data sets !
$reqRetrieve->setIds($result->getIds());

$res = $sf->Retrieve($reqRetrieve);

echo "<pre>";
print_r($res);

 

 

The toolkit is currently in beta-state and can be accessed here : 

InTradeSys / Salesforce ATP

 

Please be aware that we are currently only giving access to the download area after a short registration (double opt-in).

 

We are looking forward for receive feedback from the developer community !

 

best wishes

 

Carsten Harnisch

-- Director, InTradeSys Limited 

Hi Guys,

I use WWW::Salesforce to create accounts, contacts and opportunities in salesforce. It all works nicely until I try to send customer names that use special characters other than ascii.

 

These when viewed in salesforce look as if the encoding is broken. AFAIK SOAP::Lite which WWW::Salesforce uses is utf8 per default (I tried setting it manually, no success).

 

Interstingly, when I use Encode::encode_utf8 on the strings I pass on to the hash (see below) Dumper prints the strings properly (and no, it does not work without that call as well). So I'm thinking, I got the strings properly utf8-ed. Still, no success on the salesforce side. Could it be that SOAP::Lite re-encodes them again although they are utf8? (if I leave them unencoded, the string that arrives is a different one but still broken). Here are the details:

 

Sent string (contact name): 2äöäöääö

 

Arrived string: 2äöäöääö

 

Dumper output:

$VAR1 = {
          'Phone' => undef,
          'MailingCountry' => undef,
          'FirstName' => '1lölölööl',
          'Login__c' => 'eetestu14',
          'LastName' => '2äöäöääö',
          'MailingStreet' => undef,
          'Email' => 'XXXXXXXXX'
          'type' => 'contact',
          'AccountId' => 'XXXXXXXX',

};

 

Perl code:

use Encode;

my $contact =
  {

    'type'=> 'contact',

    'AccountId' => $accountId,   

    'FirstName' => encode_utf8($user->getFirstName()),
    'LastName' => encode_utf8($user->getLastName()),
    'Login__c' => $user->getLogin(),
    'Email' => $user->getEmail(),
    'Phone' => $user->getContactPhone(),
    'MailingStreet' => $user->getContactAddress1(),
    'MailingCountry' => $user->getContactCountry(),
  };
 $res = $self->sf()->create(%$contact);

 

So, any ideas what I might be doing wrong?

 

Cheers,

Emil