+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 22
This is a discussion on Connecting PHP form to Salesforce within the Salesforce PHP Tutorials forums, part of the Salesforce category; Hi All, I apologize if this topic is already covered in the
  1. #1
    riya is offline Junior Member
    Join Date
    May 2010
    Posts
    5

    Connecting PHP form to Salesforce

    Hi All,

    I apologize if this topic is already covered in the earlier posts. I am a beginner in both PHP and Salesforce. My current assignment is I need to connect PHP form which accepts donations through credit cards to Salesforce opportunity.Once the payment is made I need to transfer the donation information to Salesforce. I am using nonprofit starter pack for Salesforce. Could any one please give me direction to start this? Your help is greatly appreciated.

    Thank you,
    Riya

  2. #2
    Willis's Avatar
    Willis is offline Administrator
    Join Date
    Feb 2010
    Location
    Sunnyvale, CA
    Posts
    19
    Blog Entries
    9
    Hi Riya and welcome to the website!

    Let's start off with a few basic questions:

    1.) What data points are you collecting in your webform?
    2.) By beginner, how much experience do you have in both PHP and Salesforce?
    3.) Do you know if the non-profit edition of Salesforce.com gives you access to the Webservices API?

    Also, if you have any code that you've tried or could be more specific the actual process it would be great. If your goal is to simply pass details from the web form to an opportunity, it should actually be really straight forward.

    Looking forward to hearing back from you.

    ~Will

  3. #3
    scott@pogysoft.com is offline Junior Member
    Join Date
    May 2010
    Location
    Eugene, OR
    Posts
    7
    Re: 3) Isn't nonprofit Salesforce is based on one of the commercial editions of Salesforce?
    (We have NonProfit Salesforce and can access it through the API because it is based on Enterprise Edition.
    Riya, which commercial edition it is based on?).

  4. #4
    Willis's Avatar
    Willis is offline Administrator
    Join Date
    Feb 2010
    Location
    Sunnyvale, CA
    Posts
    19
    Blog Entries
    9
    Hi Scott,

    We run EE so I wasn't 100% familiar with regard to the other options. If Non Profit is based off EE then we're in good shape, just wanted to confirm.

  5. #5
    riya is offline Junior Member
    Join Date
    May 2010
    Posts
    5
    Hi Will,

    Thank you for your reply. Following are my answers to your questions.

    1. What data points are you collecting in your webform?
    I am collecting following details:

    Donation For --> drop down list
    other:

    Donation Amount US Dollar

    Contact information
    First Name, Last Name, Address Line 1, Address Line 2, City, State, ZIP/Postal Code, country, phone, email

    Payment Information:
    Cardholder's Name, credit Card Number, Credit Card Type and Expiration Date

    Optional:
    Donate in honor of someone:

    2. Experience

    I installed PHP 5.5 on IIS web server. I am practicing beginner tutorial.
    I just completed course on Salesforce development.I know different components in Salesforce and basic knowledge on APEX and Visualforce.

    3. I am assuming that it provides access to Webservices API since Nonprofit starter pack is based on Enterprise edition.

    I have requested non profit organization to send me PHP code they have used to develop donation form and I will get it soon.

    Since I do not have code now, I would like to try how simple PHP contact form is connected to Salesforce. I will pass contact details from php form to Salesforce lead entity. This exercise is to know how the basic connection is done from PHP to Salesforce. Could you please send me any sample PHP form with Salesforce connection details? Please guide me on this.

    Thank you,
    Riya

  6. #6
    riya is offline Junior Member
    Join Date
    May 2010
    Posts
    5
    Hi Scott,

    Thank you for your reply. Our Nonprofit Salesforce edition is based on Enterprise edition.

    Thank you,
    Riya

  7. #7
    Willis's Avatar
    Willis is offline Administrator
    Join Date
    Feb 2010
    Location
    Sunnyvale, CA
    Posts
    19
    Blog Entries
    9
    Hi Riya,

    This is Mike's territory for the PHP connection to your salesforce.com org but I can give you some gotchas:

    1.) Keep the login credentials and the actual script in two different places and simply call the login credentials. The biggest reason for this is because the security tokens could bite you at the end of the day and having it all in one spot is convenient.

    2.) If you have a dev environment and you for some reason use URLs, make sure you switch those up.

    3.) Be careful of validation rules... they'll bite you if you're not careful

    Once Mike posts the connections, we can figure out how to map the data from your form into Salesforce

  8. #8
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16

    Wink This should help

    Riya -

    First do me a favor and never apologize for asking a question, no matter how small it is....

    This site is about helping people and that is it. Listen like Will said, thanks for joining the site

    Let's see if we can get you started, I am going to ask you a few questions though:

    1) Since you installed PHP on a Windows machine, have you been able to get it to connect to Salesforce at all? I am guessing not

    A) First you will need to download the PHP Tool Kit from Salesforce.com, which I am attaching to this post.

    B) Then you will need to ensure that your connection to Salesforce is working. Here is some code for a central login script which you can use in all your PHP scripts by just including it. This saves you time when you have to change your password for Salesforce and not having to change it in a ton of scripts:

    PHP Code:
    <?php

    require_once ('/users/msimonds/public_html/includes/soapclient_new/SforcePartnerClient.php');
    require_once (
    '/users/msimonds/public_html/includes/soapclient_new/SforceHeaderOptions.php');

    // Login to salesforce.com
    $login 'you@email.com';
    $password 'password';
    $key 'Your Key Here';

    //join Password and Key here 
    $password $password $key;

    $wsdl "/users/msimonds/public_html/includes/soapclient_new/partner.wsdl.xml";

    $client = new SforcePartnerClient();
    $client->createConnection($wsdl);

    try
    {
        
    $loginResult $client->login($login$password);

        if (
    $loginResult->passwordExpired)
        {

            unset(
    $client);
        }
    }
    catch (
    exception $e)
    {
        
    $error '<pre>' print_r($etrue) . '</pre>';
        
    mail('you@email.com''Salesforce Login Error'$error);
        unset(
    $client);

    }

    ?>
    C) Make sure that you change all the necessary information in the script, such as the paths to match your server and the login information.
    D) When you download the toolkit there is a WSDL file in the download called the partner.wsdl.xml file. I would login to your salesforce organization and navigate to Setup > App Setup > API and you will see different WSDL files. Get a new copy of the partner WSDL file and replace the one that is in the toolkit. This will give you the most updated WSDL file.

    2) Now call that login php script from the browser and see if you get any errors.

    3) If you do not then we can get on with the form and how to get the data into Salesforce. If you do get errors, we will need to fix those prior to getting started


    I hope this helps!!

    ~Mike
    Attached Files Attached Files

  9. #9
    riya is offline Junior Member
    Join Date
    May 2010
    Posts
    5
    Hello Mike,

    Thank you for helping me to start my assignment in the right direction. As you mentioned, I downloaded PHP tool kit. I replaced the partner.wsdl.xml file with newly generated partner.wsdl.xml file from Salesfore.Finally I made modifications to PHP file according to my user id, password and path.
    When I called login php from a firefox browser, I get blank page. No error message. When I gave some print statement it is showing that on output.If the print statement is after the following statement i$client->createConnection($wsdl); print statement is not displaying.
    How can I debug this? Does it have problem with newly generated WSDL? Please help me on this.

    Thank you,
    Riya

  10. #10
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    Can you turn on Error Reporting? Turn on Error Reporting to see if anything renders to your browser

    Also after the Try block and $loginResult

    Do a print_r($loginResult) and see what the screen says

    I am not sure your PHP is setup correctly. Do you have SSL enabled on PHP?

    Is there anyway I can see a PHPinfo () of your server?

    ~Mike

+ Reply to Thread
Page 1 of 3 123 LastLast

Similar Threads

  1. Salesforce PHP form Help
    By sarma in forum Salesforce Coding Discussions
    Replies: 9
    Last Post: 08-12-2007, 09:03 PM
  2. Connecting to Salesforce using ADOdb
    By mike in forum Salesforce Coding Discussions
    Replies: 0
    Last Post: 07-30-2007, 02:55 PM

Tags for this Thread

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