You need to sign in to do that
Don't have an account?

[PHP] cURL problems; web-to-lead
How can I have PHP send data from a web form to salesforce.com? I am trying to ultimately have the user fill out the form, hit the submit button, validate the form then send the data to salesforce.com (if the form is valid) without refreshing the page. I am using cURL to do the PHP work.
The code below is in isolation. This should work by itself, correct?
* the 'oid' value is fake.
Code:
<?php $data = array( 'first_name'=> 'Marc', 'last_name' => 'Kass', 'email' => 'marckass@example.com', 'submit' => 'true', 'oid' => '11X011111111xX1' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.salesforce.com/servlet/servlet.WebToLead–encoding=ISO-8859-1"); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $postResult = curl_exec($ch); curl_close($ch); ?>
Any comments?
Any suggestions?
thanks
That blog post has PHP files you can download that should "just work".
You can learn a bit more about it by watching the Dreamforce video from the PHP Session. Once you get to that link, click to view the session materials. My part is the second part.
In short, the following is how I do it:
Ah…thank you so much for your comment! I have been seriously working on this for about 3 weeks and haven’t accomplished much. I will read your blog article(s) tomorrow and will definitely post my status.
Message Edited by marc_____ on 12-21-2007 04:56 PM
Ok, I tried eliminating the Akismet code for now and I was unable to get a lead into salesforce.com.
So now I am going to try again strictly as you have it. I am a little perplexed by step 1
For step 1; I went to the following URL…;
https://na4.salesforce.com/ui/setup/Setup?setupid=Lead
…and then clicked on ‘Fields’. Is this where I create the checkbox field to “hold whether or not Akismet thinks that it is spam”? I am thinking it is since steps 3.4 now makes sense. In which I would just click on 'Web to Lead' from that URL I posted to retrieve the id value.
Thanks again for your time!
Thanks again hemm! I used your code “as is” and it works smoothly!
I am still unsure why it was not running when I hacked out the Akismet code, but no big deal, I am just glad I can connect to salesforce.com now. Now I will have an anti-spam feature for the app, even better. :)
I have tried to send data through curl
but after submmiting form i am getting error below
please help to shortout
"Salesforce could not create this lead because of the reason listed below. For more information about this error or help with Web-to-Lead, please contact Customer Support.
Reason: There's a problem with this country, even though it may appear correct. Please select a country/territory from the list of valid countries. "