+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 16
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)
  1. #1
    mramsey is offline Junior Member
    Join Date
    Mar 2008
    Posts
    15

    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

  2. #2
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    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

  3. #3
    mramsey is offline Junior Member
    Join Date
    Mar 2008
    Posts
    15
    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('&''&amp;'$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:

  4. #4
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    Quote Originally Posted by mramsey View Post
    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('&''&amp;'$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

  5. #5
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    I actually tested this script and was able to login on my localhost

  6. #6
    mramsey is offline Junior Member
    Join Date
    Mar 2008
    Posts
    15
    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?

  7. #7
    mramsey is offline Junior Member
    Join Date
    Mar 2008
    Posts
    15
    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

  8. #8
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    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(); 

  9. #9
    mramsey is offline Junior Member
    Join Date
    Mar 2008
    Posts
    15
    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

  10. #10
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    Quote Originally Posted by mramsey View Post
    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

+ Reply to Thread
Page 1 of 2 12 LastLast

LinkBacks (?)

  1. Hits: 1
    05-02-2012, 09:04 AM
  2. Hits: 1
    11-29-2009, 09:14 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO 3.5.2