 |
| This is a discussion on Script can't log into production within the Salesforce Coding Discussions forums, part of the Salesforce category; I've downloaded two separate partner.wsdl.xml files one from my sandbox (named partner.wsdl.xml_sandbox) |

03-27-2008, 05:06 PM
|
|
Junior Member
|
|
Join Date: Mar 2008
Posts: 8
|
|
Script can't log into production
|
|
I've downloaded two separate partner.wsdl.xml files one from my sandbox (named partner.wsdl.xml_sandbox) and one from my production (named partner.wsdl.xml) I've tried both with both production and sandbox admin username and passwords it will connect with sandbox user credentials no matter which wsdl file i use.
Won't connect to production no matter which file i use. I don't have any char's that need escaping in the password (in fact, the passwords are the same for sandbox and prod) the only difference is the username if prod is user@domain.com and for sandbox it's user@domain.com.sandbox
I've added server IP to the whitelist and i've tried with and without security token... Please help.
thanks in advance,
Mike
|

03-28-2008, 07:18 AM
|
|
Administrator
|
|
Join Date: May 2007
Posts: 246
|
|
Mike thanks for joining the site, I appreciate it!
Listen there are a few items that need to be checked so we can troubleshoot this!
Is your PHP setup correctly? do you have SOAP enabled and SSL?
What errors are you getting, can you do a print_r or var_dump, this would help
Hope this makes sense
~Mike
|

03-28-2008, 09:39 AM
|
|
Junior Member
|
|
Join Date: Mar 2008
Posts: 8
|
|
Correct me if I'm wrong but SOAP is installed because it connects to sandbox right?
Also, i'm not sure what you want me to print_r?
Here's the code:
PHP Code:
<form enctype="multipart/form-data" method="POST"> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload" /> </form> <?php $target="uploads/"; $target=$target.basename($_FILES['uploaded']['name']); if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { $fp=fopen($target,'r'); $k=0; require_once ('soapclient/SforcePartnerClient.php'); $mySforceConnection = new SforcePartnerClient(); $mySoapClient = $mySforceConnection->createConnection("partner.wsdl.xml"); $mylogin = $mySforceConnection->login("user@domain.com", "password"); while(!feof($fp)) { $line=fgets($fp); if($line==''){continue;} $line = explode("\t",str_replace('&', '&', $line)); $id[$k]['id']=$line[0]; $id[$k]['name']=str_replace('"','',$line[1]); $k++; } foreach($id as $creditorid) { $query="SELECT Creditor_Id__c from Creditor__c where Creditor_Id__c='".$creditorid['id']."'"; $queryResult = $mySforceConnection->query($query); $records= $queryResult->records; if(count($records)<1){ $fieldsToInsert = array('Name'=>$creditorid['name'],'Creditor_Id__c'=>$creditorid['id']); print_r($fieldsToInsert); echo "<br />"; $sObject = new SObject(); $sObject->fields = $fieldsToInsert; $sObject->type = 'Creditor__c'; $lead = $mySforceConnection->create(array ($sObject),'Creditor__c'); }else{echo "Skipped<br />";continue;} }}
The error is :
PHP Fatal error: Uncaught SoapFault exception: [ns1:INVALID_LOGIN] INVALID_LOGIN: Invalid username or password or locked out. in /var/www/html/sf/soapclient/SforceBaseClient.php:113\nStack trace:\n#0 [internal function]: SoapClient->__call('login', Array)\n#1 /var/www/html/sf/soapclient/SforceBaseClient.php(113): SoapClient->login(Array)\n#2 /var/www/html/sf/script.php(16): SforceBaseClient->login(user@domain.com', 'password')\n#3 {main}\n thrown in /var/www/html/sf/soapclient/SforceBaseClient.php on line 113, referer:
|

03-28-2008, 10:18 AM
|
|
Administrator
|
|
Join Date: May 2007
Posts: 246
|
|
Quote:
Originally Posted by mramsey
Correct me if I'm wrong but SOAP is installed because it connects to sandbox right?
Also, i'm not sure what you want me to print_r?
Here's the code:
PHP Code:
<form enctype="multipart/form-data" method="POST"> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload" /> </form> <?php $target="uploads/"; $target=$target.basename($_FILES['uploaded']['name']); if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { $fp=fopen($target,'r'); $k=0; require_once ('soapclient/SforcePartnerClient.php'); $mySforceConnection = new SforcePartnerClient(); $mySoapClient = $mySforceConnection->createConnection("partner.wsdl.xml"); $mylogin = $mySforceConnection->login("user@domain.com", "password"); while(!feof($fp)) { $line=fgets($fp); if($line==''){continue;} $line = explode("\t",str_replace('&', '&', $line)); $id[$k]['id']=$line[0]; $id[$k]['name']=str_replace('"','',$line[1]); $k++; } foreach($id as $creditorid) { $query="SELECT Creditor_Id__c from Creditor__c where Creditor_Id__c='".$creditorid['id']."'"; $queryResult = $mySforceConnection->query($query); $records= $queryResult->records; if(count($records)<1){ $fieldsToInsert = array('Name'=>$creditorid['name'],'Creditor_Id__c'=>$creditorid['id']); print_r($fieldsToInsert); echo "<br />"; $sObject = new SObject(); $sObject->fields = $fieldsToInsert; $sObject->type = 'Creditor__c'; $lead = $mySforceConnection->create(array ($sObject),'Creditor__c'); }else{echo "Skipped<br />";continue;} }}
The error is :
PHP Fatal error: Uncaught SoapFault exception: [ns1:INVALID_LOGIN] INVALID_LOGIN: Invalid username or password or locked out. in /var/www/html/sf/soapclient/SforceBaseClient.php:113\nStack trace:\n#0 [internal function]: SoapClient->__call('login', Array)\n#1 /var/www/html/sf/soapclient/SforceBaseClient.php(113): SoapClient->login(Array)\n#2 /var/www/html/sf/script.php(16): SforceBaseClient->login(user@domain.com', 'password')\n#3 {main}\n thrown in /var/www/html/sf/soapclient/SforceBaseClient.php on line 113, referer:
|
Ahh I missed that man, sorry I did not know that you are getting logged into your sandbox okay!!! My mistake
I wanted you to print_r that error message that you just posted, Ha!
listen Try this
PHP Code:
<?php
$user = 'user@domain.com'; $pass = 'password';
/* this is the key that I generated from my development account * which allows you to bipass the IP check in Salesforce * go to salesforce > My personal Information > Reset my security Token*/
$pass_string = 'L07opnWnbTKrvJ3wcpFiWyTsl';
$pass = $pass.$pass_string;
require_once ('soapclient/SforcePartnerClient.php'); $mySforceConnection = new SforcePartnerClient(); $mySoapClient = $mySforceConnection->createConnection("partner.wsdl.xml"); $mylogin = $mySforceConnection->login($user, $pass);
if ($mylogin) { echo "logged in"; } else { echo "crap, something is wrong"; }
?>
let me know if this makes sense or if this is completely idiotic!!
~Mike
|

03-28-2008, 10:19 AM
|
|
Administrator
|
|
Join Date: May 2007
Posts: 246
|
|
I actually tested this script and was able to login on my localhost
|

03-28-2008, 10:45 AM
|
|
Junior Member
|
|
Join Date: Mar 2008
Posts: 8
|
|
OK with your script same issue failed to log in.. So i downloaded the enterprise wsdl and changed it to use that script and now it logs in .. so i tried that with my script and indeed it does log in.. (weird the partner wsdl file doesn't allow for logging in) But now with my original script i get error:
PHP Fatal error: Uncaught SoapFault exception: [soapenv:Client] Element {}item invalid at this location in /var/www/html/sf/soapclient/SforceBaseClient.php:457\nStack trace:\n#0 [internal function]: SoapClient->__call('query', Array)\n#1 /var/www/html/sf/soapclient/SforceBaseClient.php(457): SoapClient->query(Array)\n#2 /var/www/html/sf/creditor.php(42): SforceBaseClient->query('SELECT Creditor...')\n#3 {main}\n thrown in /var/www/html/sf/soapclient/SforceBaseClient.php on line 457, referer:
any suggestions on this?
|

03-28-2008, 11:12 AM
|
|
Junior Member
|
|
Join Date: Mar 2008
Posts: 8
|
|
Ok making a little more progress.. i've created a new script:
PHP Code:
require_once ('soapclient/SforceEnterpriseClient.php'); $mySforceConnection = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnection->createConnection("enterprise.wsdl.xml"); $mylogin = $mySforceConnection->login("user@domain.com", "password"); $query = "SELECT ID, Name from Account where Client_Id__c='xxxxxx'"; $queryResult = $mySforceConnection->query(($query)); $records = $queryResult->records; foreach($records as $record) { $sObject = new SObject($record); $name=$sObject->fields->Name; $creditorid=$sObject->Id; echo "Name: $name<br />"; echo "ID: $creditorid<br />"; }
with this though i'm getting:
PHP Fatal error: Class 'SObject' not found in /var/www/html/sf/test.php on line 15
any thoughts?
Sorry for being such a pain...
-Mike
|

03-28-2008, 11:21 AM
|
|
Administrator
|
|
Join Date: May 2007
Posts: 246
|
|
You're not a pain
Some of your stuff helps me too
I think that when using the enterprise client, you need this:
PHP Code:
$sObject = new stdclass();
|

03-28-2008, 11:37 AM
|
|
Junior Member
|
|
Join Date: Mar 2008
Posts: 8
|
|
Alrighty... new code:
PHP Code:
require_once ('soapclient/SforceEnterpriseClient.php'); $mySforceConnection = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnection->createConnection("enterprise.wsdl.xml"); $mylogin = $mySforceConnection->login("user@domain.com", "password"); $query = "SELECT ID, Name from Account where Client_Id__c='xxxxx'"; $queryResult = $mySforceConnection->query(($query)); $records = $queryResult->records; print_r($records); echo "<br />"; echo "Number of Results: ".count($records)."<br />"; foreach($records as $record) { $sObject = new stdclass($record); $name=$sObject->fields->Name; $creditorid=$sObject->Id; echo "Name: $name<br />"; echo "ID: $creditorid<br />"; }
Results seen in internet explorer when script is ran:
Array ( [0] => stdClass Object ( [Id] => 0015000000LUPX3AAP [Name] => Test Test ) )
Number of Results: 1
Name:
ID:
and error messages received:
PHP Notice: Undefined property: stdClass::$fields in /var/www/html/sf/test.php on line 16
PHP Notice: Trying to get property of non-object in /var/www/html/sf/test.php on line 16
PHP Notice: Undefined property: stdClass::$Id in /var/www/html/sf/test.php on line 17
|

03-28-2008, 01:19 PM
|
|
Administrator
|
|
Join Date: May 2007
Posts: 246
|
|
Quote:
Originally Posted by mramsey
Alrighty... new code:
Results seen in internet explorer when script is ran:
Array ( [0] => stdClass Object ( [Id] => 0015000000LUPX3AAP [Name] => Test Test ) )
Number of Results: 1
Name:
ID:
and error messages received:
PHP Notice: Undefined property: stdClass::$fields in /var/www/html/sf/test.php on line 16
PHP Notice: Trying to get property of non-object in /var/www/html/sf/test.php on line 16
PHP Notice: Undefined property: stdClass::$Id in /var/www/html/sf/test.php on line 17
|
Try to add this to your foreach:
PHP Code:
foreach ($records as $record) { $sObject = new stdclass($record); $name = $sObject->fields->Name; $creditorid = $sObject->Id; echo '<pre>' . print_r($record,true) . '</pre>'; echo "Name: $name<br />"; echo "ID: $creditorid<br />"; }
OR
PHP Code:
foreach ($records as $record) { $sObject = new stdclass($record); $name = $sObject->fields->Name; $creditorid = $sObject->Id; echo '<pre>' . print_r($sObject,true) . '</pre>'; echo "Name: $name<br />"; echo "ID: $creditorid<br />"; }
and print both to the screen please
|
| Thread Tools |
|
|
| Rate This Thread |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |