1 / 16

sForce 2P out of 3P: Perl and PHP

Presented by Byrne Reese Product Manager, TypePad – Six Apart Lead Developer – SOAP::Lite Project. sForce 2P out of 3P: Perl and PHP. Agenda. Take a closer look at the sForce Perl Project Introducing php_gen_proxy. Why SOAP::Lite?. Pro’s Simple API PERL’s utility goes way beyond the Web

terrel
Download Presentation

sForce 2P out of 3P: Perl and PHP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Presented by Byrne Reese Product Manager, TypePad – Six ApartLead Developer – SOAP::Lite Project sForce 2P out of 3P: Perl and PHP

  2. Agenda • Take a closer look at the sForce Perl Project • Introducing php_gen_proxy

  3. Why SOAP::Lite? Pro’s • Simple API • PERL’s utility goes way beyond the Web • Ubiquity of Perl • Excellent developer support, and 3rd party tool set • SOAP over HTTP, FTP, Jabber, and more Con’s • Document-Literal Support in Beta

  4. SOAP::Lite – A Quick Update • Current version: 0.65 Beta 2 • Changes in 0.65 • Document-literal support • DIME support • Much improved documentation • Enhanced attachment management • Many interoperability fixes

  5. Perl: Salesforce Module • Originally written for last year's dreamForce conference • What has changed in 2004? • Support for all 4.0 operations (with 5.0 to come) • Added additional unit tests and code samples • Added much needed documentation

  6. Perl: Installation • Install SOAP::Lite> perl –MCPAN –e ‘install SOAP::Lite’ • Download Salesforce-0.54.tar.gz fromhttp://majordojo.com/salesforce • Unpack Salesforce-0.54.tar.gz • Run the standard:> cd Salesforce-0.54> perl Makefile.PL> make> make test> make install

  7. Perl: login • Session ID is automatically persisted for subsequent calls #!/usr/bin/perl use Salesforce; my $service = new Salesforce::SforceService; my $port = $service->get_port_binding('Soap'); $port->login('username' => ‘byrne@majordojo.com’, 'password' => ‘xxxxxxxxx’); print “My Session ID: “.$port->{'sessionId'}.”\n”;

  8. Perl: query • Perform a Query… #!/usr/bin/perl use Salesforce; my $service = new Salesforce::SforceService; my $port = $service->get_port_binding('Soap'); $port->login('username' => ‘byrne@majordojo.com’, 'password' => ‘xxxxxxxxx’); $result = $port->query('query' => "select Id,Name from Account", 'limit' => 10);

  9. Perl: query (cont.) • Parse the results #!/usr/bin/perl use Salesforce; ... $result = $port->query('query' => ‘SELECT Id,Name FROM Account’, 'limit' => 10); foreach my $elem ($result->valueof('//queryResponse/result/records')) { printf "%s, %s\n", $elem->{Id},$elem->{Name}; }

  10. Perl: Additional Resources • Salesforce Module man page • Salesforce Perl Module Homehttp://majordojo.com/salesforce/ • SOAP::Lite HOWTOs & Solutionshttp://majordojo.com/soaplite/ • SOAP::Lite Project Homepagehttp://www.soaplite.com/ • O’Reilly’s Programming Web Services with Perl, Randy J. Ray and Paul Kulchenko

  11. PHP: Why Pear SOAP? • PHP is tailored for the Web • Simpler syntax • WSDL Support

  12. PHP: php_gen_proxy • What it does: • Generates PHP code stubs that work against any SFDC WSDL • Why use it? • Pear SOAP's gen_proxy.php tool does not generate the necessary bindings to send SOAP Headers • A bug in Pear SOAP prevents Header definitons from being read properly in WSDLs

  13. PHP: Installation • Prerequisites: • Pear SOAP • PHP 4.3.4 or greater (compiled with –with-zlib and –with-curl flag) • Install required Pear Modules:> pear install -fa SOAP-0.8RC3

  14. PHP: Installation (cont.) • Download php_gen_proxy-0.50.tar.gz (Windows Zip file also available) from:http://majordojo.com/salesforce • Unpack php_gen_proxy-0.50.tar.gz • Patch SOAP/WSDL> patch /usr/local/lib/php/SOAP/WSDL.php WSDL.patch • Generate Code Stubs:> php gen_sfdc_proxy.php <wsdl> • Code

  15. PHP: Sample Code <?php require_once("SalesforceClient.php"); $client = new SalesforceClient(); $result = $client->login(“byrne@majordojo.com”,”xxxxxxx”); if (PEAR::isError($result)) { echo "Error: " . $result->getMessage() . "\n"; exit; } $result = $client->query("select Id,FirstName,LastName from Lead"); while (list($k1, $record) = each($result->records)) { printf("%s %s, %s\n",$record->{'Id'}[0], $record->{'LastName'},$record->{'FirstName'}); } ?>

  16. PHP: Additional Resources • php_gen_proxy Homepagehttp://www.majordojo.com/salesforce/ • PHP Project Homepagehttp://www.php.net • Pear Networkhttp://pear.php.net • Pear SOAP Homehttp://pear.php.net/package/SOAP

More Related