• David98
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hello,
We've been using the Perl API since October for a 'web to lead' type application. Since the new year, we've been experiencing a lot of problems with the API not sending the data to Salesforce.
The code has an error check in it where we check for "success" in the XML, but that code never executes. When we look at our logs, we see that there is no "success" variable to check. Almost like we aren't receiving a response at all.

Has anyone else experienced these intermittent problems? If so, have you fixed them and how?

I've posted our code here in case there is something messed up with it. Thanks in advance!

Code:
#START Salesforce
use WWW::Salesforce::Simple;
 # Authenticate with the Salesforce API based on command line parameters.
 my $sforce = WWW::Salesforce::Simple->new(
  'username' => 'xxxxxxxx@xxxxxxxxx.xxx',
  'password' => 'xxxxxx'
 );

 #create lead
 my %lead;
 $lead{'type'} = 'Lead';

 my ($first, $last) = split(/ /, $FORM{'contact'}, 2);
 unless ($last) {
  $last = $first; $first = "";
 }
 $lead{'FirstName'} = $first if $first;
 $lead{'LastName'}  = $last if $last;

 $lead{'Company'} = $FORM{'company'};
        $lead{'Street'} = $FORM{'address1'} . " " . $FORM{'address2'};
        $lead{'City'} = $FORM{'city'};
        $lead{'State'} = $FORM{'state'};
        $lead{'PostalCode'} = $FORM{'zip'};
 $lead{'Phone'} = $FORM{'phone'};
 $lead{'Website'} = $FORM{'url'};
 $lead{'Email'} = $FORM{'email'};
        if (length($FORM{'other'}) > 0) {
         $lead{'LeadSource'} = $FORM{'source'} . " -- " . $FORM{'other'};
        } else {
         $lead{'LeadSource'} = $FORM{'source'};
 }
        $lead{'Sales_Region__c'} = $FORM{'salesregion'};
        $lead{'Found_us_from__c'} = $fus;
        $lead{'Sales_Description__c'} = $FORM{'descript'};
        $lead{'URL_Title__c'} = $FORM{'title'};
        $lead{'Initial_Keywords__c'} = $FORM{'keywords'};
        $lead{'Google_Results__c'} = "PageRank:$rf[3]\n    Inbound Links: $rf[4]\n    Site Pages Spidered: $rf[5]\n\n";


 #submit lead to salesforce
 my $res = $sforce->create(%lead);
 if ($res->result->{"success"} == "false") {
  print $res->result->{errors}->{message} . '\n';
 }
# END Salesforce