+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 11

Thread: error in sample code

  1. #1

    error in sample code

    hello mike

    i am new to salesforce php i download the toolkit and install and testing the sample code in which is in the toolkit when run the login.php and given the developer salesforce account details and submit it is giving this error

    POST /services/Soap/u/11.1 HTTP/1.1 Host: CRM - The Leader In Software-as-a-Service (SaaS) - salesforce.com CRM - salesforce.com Connection: Keep-Alive User-Agent: PHP-SOAP/5.2.8 Accept-Encoding: gzip, deflate Content-Type: text/xml; charset=utf-8 SOAPAction: "" Content-Length: 339

    please help me

    thank you
    mubbu

  2. #2
    Join Date
    May 2007
    Posts
    502
    Blog Entries
    3
    Quote Originally Posted by mubbu View Post
    hello mike

    i am new to salesforce php i download the toolkit and install and testing the sample code in which is in the toolkit when run the login.php and given the developer salesforce account details and submit it is giving this error

    POST /services/Soap/u/11.1 HTTP/1.1 Host: CRM - The Leader In Software-as-a-Service (SaaS) - salesforce.com CRM - salesforce.com Connection: Keep-Alive User-Agent: PHP-SOAP/5.2.8 Accept-Encoding: gzip, deflate Content-Type: text/xml; charset=utf-8 SOAPAction: "" Content-Length: 339

    please help me

    thank you
    mubbu

    mubbu

    thanks for joining the site!

    can you post your code so I can take a look at it?

    ~Mike

  3. #3

    toolkit code

    i am using same toolkit code of sample folder -> login.php
    PHP Code:
    require_once ('../soapclient/SforcePartnerClient.php');
    include ('header.inc');
    $errors = null;
    session_start();

    function login($username, $password) {
      $wsdl = 'partner.wsdl.xml';
      $loginResult = null;
      try {
        $mySforceConnection = new SforcePartnerClient();
        $mySforceConnection->createConnection($wsdl);
        $loginResult = $mySforceConnection->login($username, $password);

        $_SESSION['location'] = $mySforceConnection->getLocation();
        $_SESSION['sessionId'] = $mySforceConnection->getSessionId();
        $_SESSION['wsdl'] = $wsdl;

      } catch (Exception $e) {
        echo $mySforceConnection->getLastRequest();
        echo $mySforceConnection->getLastRequestHeaders();
        global $errors;
        $errors = $e->faultstring;

      }
      return $loginResult;
    }

    /**
     * Checks to see if the user has submitted his
     * username and password through the login form,
     */
    if (isset ($_POST['loginClick'])) {
      /* Check that all fields were typed in */
      if (!$_POST['user'] || !$_POST['pass']) {
        global $errors;
        $errors = ('Please fill in both username and password.');
      } else {
        /* Spruce up username, check length */
        $_POST['user'] = trim($_POST['user']);

        try {
          /* Checks that username and password are correct */
          $result = login($_POST['user'], $_POST['pass']);

          if (isset($result)) {
            session_write_close();
            header('Location: welcome.php');
            exit();
          }
        } catch (Exception $e) {
          print_r($e);
        }
      }
    }

    ?>

    <br><br>
    <div style="font-family: verdana; font-size: 14px; font-weight: bold; color: rgb(102, 102, 102);">Login</div><br>
      <div style="color: rgb(102, 102, 102);">
        If you are already a member of the AppExchange developer community, please login.
      </div><br>

    <?php
    global $errors;
    if (isset(
    $errors)) {
      echo 
    '<p><span style=\"color:#FF0000\">$errors</span></p>';
    }
    ?>

    <form action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post">
    <table align="left" border="0" cellspacing="0" cellpadding="3">
      <tr><td><strong>User Name:</strong></td><td><input type="text" name="user" maxlength="30"></td></tr>
      <tr><td><strong>Password:</strong></td><td><input type="password" name="pass" maxlength="30"></td></tr>
      <tr>
        <td colspan="2" align="right">
          <input type="submit" name="loginClick" value="Login">
        </td>
      </tr>

    </table>
    </form>

    <?php
      
    include ('footer.inc');
    ?>
    when i am login with developer salesforce account details

    Thank you
    mubbu

  4. #4
    Join Date
    May 2007
    Posts
    502
    Blog Entries
    3
    are you sure that you have SOAP enabled in your PHP setup and SSL?
    That is what it seems to be to me? Check it with a phpinfo():


    ~Mike

  5. #5

    check the php setup

    soap is enable and pasting the phpinfo() code

    soap

    Soap Client enabled Soap Server enabled
    Directive LocalValue Master Value
    soap.wsdl_cache 1 1
    soap.wsdl_cache_dir /tmp /tmp
    soap.wsdl_cache_enabled 1 1
    soap.wsdl_cache_limit 5 5
    soap.wsdl_cache_ttl 86400 86400

    openSSl is enable

    openssl

    OpenSSL support enabled
    OpenSSL Version OpenSSL 0.9.7a Feb 19 2003


    we install openSSL it make any different. Please advice

    Thank you
    mubbu
    Last edited by mubbu; 02-28-2009 at 12:22 AM.

  6. #6
    Join Date
    May 2007
    Posts
    502
    Blog Entries
    3

    this should do it for you!

    okay dude try this code:

    PHP Code:
    <?php

    ini_set
    ("soap.wsdl_cache_enabled","0");


    require_once (
    './soapclient/SforcePartnerClient.php');

    //Salesforce Connection information
    $wsdl './soapclient/partner.wsdl.xml';
    $userName "you@youremail.com";
    $password "password+key";


    //setup connection
    $client = new SforcePartnerClient();
    $client->createConnection($wsdl);
    $loginResult $client->login($userName,$password);

    if (
    $loginResult)
    {
        echo 
    "I am logged in";
    }
    else
    {
        echo 
    "someting is wrong";
    }



    ?>
    make sure to change the paths to match your WSDL file and your salesforce partner class script.

    You can cry this exact code right here to my dev version of Salesforce!

    http://www.mikesimonds.com/salesforce_test/


    The examples that are given in the toolkit are old, not updated, and sometimes have conflicts with different PHP setups. This script that I have is just a simple login script to see if you are at least connecting to Salesforce.

    Let me know if this works

    Thanks!


    ~Mike

  7. #7

    Thumbs up thank mike

    This code is working mike thank you very much

    mike you r doing very good job.

    Thank you

    mubbu

  8. #8
    Join Date
    May 2007
    Posts
    502
    Blog Entries
    3
    Glad that worked out for you man!

  9. #9

    Issue with the Code

    I tried copying the code and uploaded it http://lesterm.com/ringlead/test_.php and it displays nothing just blank page. I set path correctly. SOAP is enabled and SSL also.

  10. #10
    Join Date
    May 2007
    Posts
    502
    Blog Entries
    3
    it has something to do with your php setup man, I know SOAP and SSL are enabled, but I think it has to do with the CGI mode. I just do not know enough about this

+ Reply to Thread
Page 1 of 2
1 2 LastLast

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.0 RC1 PL1