Obama '08

               
   

Go Back   Mike Simonds > Salesforce > Salesforce Coding Discussions

This is a discussion on $loginResult keeps returning false within the Salesforce Coding Discussions forums, part of the Salesforce category; Hello all! iam glad to have found this site, very clear tutorials

Reply
 
LinkBack Thread Tools Rate Thread
  #1  
Old 12-31-2007, 11:59 AM
Junior Member
 
Join Date: Nov 2007
Posts: 10
Question $loginResult keeps returning false

Hello all! iam glad to have found this site, very clear tutorials and answers... thnx Mike!

I have a little issue that i havent been able to fix:

I have this script that was fully working in a previous server but stopped when we moved the application to a lunar pages server .

The thing is that this server required a custom SOAP configration through the .htaccessfile and the php.ini file... according to the steps I have installed the SOAP module as its supposed to...

But when i run the script $loginResult allways comes false here is what i have:

PHP Code:
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);
    
ini_set("soap.wsdl_cache_enabled""0"); 
    require_once (
'includes/soapclient/SforcePartnerClient.php');
    require_once (
'includes/soapclient/SforceHeaderOptions.php');

    if ( isset(
$_POST['process']) && $_POST['process'] == 1
    {
        
login();
    }
                  
    function 
login()
    {        
        
$wsdl 'includes/soapclient/partner.wsdl.xml';
        
$username $_POST["txtUser"];
        
$password $_POST["txtPwd"];    
                            
        try {
            
//connect to salesforce
            
session_start();
            
$client = new SforcePartnerClient();    
            
$client->createConnection($wsdl);    
            
$loginResult $client->login($username$password);
            
            if (!
$loginResult) {
                exit(
"<strong>Login failed for user <code>$username</code>.  The script is being terminated. <strong>");
            }else{                
                
$_SESSION['location'] = $client->getLocation();
                
$_SESSION['sessionId'] = $client->getSessionId();
                
$_SESSION['wsdl'] = $wsdl;
                
$_SESSION['usr'] = $username;
                
$_SESSION['pwd'] = $password;
                                
                
header ("Location: welcome.php");
            }
            
        } catch (
Exception $e) {
            echo 
'<br><br> Caught exception: ',  $e->getMessage(), "\n";            
            echo 
'<div align="center"><font color="#FF0000">Invalid Username or Password, please try again </font></div>';
        }
    } 
and these are the messages i get:

Notice: Use of undefined constant SOAP_COMPRESSION_ACCEPT - assumed 'SOAP_COMPRESSION_ACCEPT' in /home/user/public_html/sfdc/includes/soapclient/SforceBaseClient.php83

Notice: Use of undefined constant SOAP_COMPRESSION_GZIP - assumed 'SOAP_COMPRESSION_GZIP' in /home/user/public_html/sfdc/includes/soapclient/SforceBaseClient.php84

Notice: Trying to get property of non-object in /home/user/public_html/sfdc/includes/soapclient/SforceBaseClient.php114

Notice: Trying to get property of non-object in /home/user/public_html/sfdc/includes/soapclient/SforceBaseClient.php124

Notice: Trying to get property of non-object in /home/user/public_html/sfdc/includes/soapclient/SforceBaseClient.php126
Login failed for user user@address.com. The script is being terminated.


This script used to work perfectly but im going nuts trying to find what is happening...

Thnx in advance for your help and guidance

Lacho
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2  
Old 01-02-2008, 04:09 PM
Administrator
 
Join Date: May 2007
Posts: 246
Send a message via AIM to mike Send a message via MSN to mike Send a message via Yahoo to mike Send a message via Skype™ to mike

Lacho

When you say that this script used to work perfectly, do you mean this exact same script that you posted here? If that is the case and it does not work any longer, did you make some changes to your PHP configuration? Upgrade? or did you change the code at all?

Do you have the original code?

I will try your code tomorrow and see if I can get it to work or trouble shoot it and post a correction.

Sorry for the delay in responding, I have been on vacation

~Mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 01-02-2008, 04:35 PM
Junior Member
 
Join Date: Nov 2007
Posts: 10
Question

Thnx Mike!
Hope you had a wonderful holiday.

Let me write the background:

First we had this very same code working in an other server, that had soap enabled and the php.ini file cofigured and the soap info in the phpinfo() was showing correctly and the code worked ok.

Then we moved the code to a new server that required to enable manually soap https://support.lunarpages.com/knowl...es/article/313 i followed the steps but i believe its not working since its not showing in the phphinfo().

Here is the code for the .htaccess file:
*********
AddHandler x-httpd-php5 .php
suPHP_ConfigPath /home/medical/public_html
*********

Here is the code for the php.ini file:
*********
include_path = .:/usr/local/lib/php:/home/medical/pear
*********

Also added to the SforceBaseClient.php:
******
PHP Code:
require_once ('SOAP/Client.php');
// added value.php because it started to show SOAP_header class not found, (dont know it this is correct though)
require_once ('SOAP/Value.php'); 
******

Then I went to the apex wiki and saw a little change on the code PHP Toolkit 1.1 Getting Started - ApexDevNet already tried using enterprise and partner with same results.

I still get the same results.

I think I must be doing something wrong with the SOAP enablement.

I appreciate your help.

Lacho
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 01-03-2008, 07:05 AM
Administrator
 
Join Date: May 2007
Posts: 246
Send a message via AIM to mike Send a message via MSN to mike Send a message via Yahoo to mike Send a message via Skype™ to mike

Lacho,

Yes you need to enable SOAP.

Is this a linux machine? if so, you have to enable it when you install it

Look at the attached picture!

Is this a host that does not have it enabled? if so, they can do it for you or should I say > They should do it for you

~Mike
Attached Thumbnails
loginresult-keeps-returning-false-soap_enable.jpg  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old 01-03-2008, 12:45 PM
Junior Member
 
Join Date: Nov 2007
Posts: 10
Thumbs up

Hello Mike!

The application now works so let me share a few comments regarding this 4 day nighmare.

After a lot of back and forth emailing with the host and after 3 days waiting for a reply to my ticket they finally enabled soap, even though they said that it was already enabled it wasnt.

Their solution to enable soap?
1. To add 2 folders to my root named /lib/php/ and copied the soap.so and a soap.la files
2. Modified the php.ini file adding:
extension_dir = /home/username/lib/php
extension = soap.so

On my side, this is what I did:

I want to make another comment regarding the apex wiki. (PHP Toolkit 1.1 Getting Started - ApexDevNet)

There is a section that shows an example of how to connect using the partner wsdl

PHP Code:
require_once ('soapclient/SforceEnterpriseClient .php');

$mySforceConnection = new SforcePartnerClient();
$mySoapClient $mySforceConnection->createConnection("partner.wsdl.xml");
$mylogin $mySforceConnection->login("username@mail.com""changeme"); 
Please note its using the SforceEnterpriseClient.php and then tries to create a new SforcePartnerClient, this does not work the first line should read
PHP Code:
require_once ('soapclient/SforcePartnerClient .php'); 
Another note worth to mention regarding the hosting server:

In my root directory I have /public_html and also have /www.
I was using the /public_html to store my files inside (/public_html/sfdc/all application files here)

I noticed that when the host created a phpinfo() file they stored it inside the /www not the /public_html so even though they are supposed to have the same files (I think) I had one more file in the /www than in /public_html. SO I put all the application files inside /www/sfdc

Also to the SforceBasweClient.php i added:
PHP Code:
require_once ('SOAP/Client.php'); 
(this is the pear file)


So finally the application is working, I am using some ajax so I am currently modifying that.

Now I can say: Feliz Aņo Nuevo!! (Happy New Year!!)

Mike thnx for your help!

Greetings from MX!!

Lacho

Last edited by lachof; 01-03-2008 at 12:52 PM. Reason: Data update
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump



Powered by vBulletin


SEO by vBSEO 3.2.0 RC8 ©2008, Crawlability, Inc.

1 2 3 4 5