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
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
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:
The error is :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;}
}}
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
let me know if this makes sense or if this is completely idiotic!!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";
}
?>
~Mike
I actually tested this script and was able to login on my localhost
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?
Ok making a little more progress.. i've created a new script:
with this though i'm getting: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 />";
}
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
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();
Alrighty... new code:
Results seen in internet explorer when script is ran: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 />";
}
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:
ORPHP 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 />";
}
and print both to the screen pleasePHP 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 />";
}
Bookmarks