Let me reiterate my gratefulness for the help guys. I would still be stabbing around in the dark pulling my hair out if it wasn't for the both of you.
The script that phphelpme gave me worked!! Google was directly retrieved after inputting FOLLOWLOCATION.
RCA86 wrote:curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
Now we can be sure cURL is working. However I still can't get the post to work. I tried two different scripts, both which I found online and modified slightly.
The first can be seen at
joshwardini.com/sandbox/curl.php. You can see that we are redirected from zoho to manageengine.com upon execution. I just substituted strings in for the values of post for the time being so I wouldn't have to enter info into the form every time. It would appear that this script doesn't use the _POST but instead passes values through the url. This could be why it's not being accepted. The the strange characters are some sort of encoding that pertains to the particular zoho account I am working with. I have modified them in this forum post for security purposes.
Code: Select all
<?php
extract($_POST);
$url = 'https://crm.zoho.com/crm/WebToLeadForm';
$fields = array(
'xnQ6asfgp' => '*5t626sgVJI$',
'xmIfafD' => 'nGtvJTI-26fg363Rr6PHYDTxR5kYBU',
'actionType' => 'TGVh43ag',
'Last Name'=>urlencode("Joe"),
'First Name'=>urlencode("Schmoe")
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
// set referer:
curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// This allows you to type things like google.com and not http://www.google.com
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
print_r($result);
?>
The second actually uses _POST but returns no output, no html and no entry in the database. I got this one from
http://curl.haxx.se/libcurl/php/example ... epost.html
Code: Select all
<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
//
$post_data = array(
'xnQsjsdp' => '*5tv2RVJI$',
'xnQ6asfgp' => '*5t626sgVJI$',
'xmIfafD' => 'nGtvJTI-26fg363Rr6PHYDTxR5kYBU',
'actionType' => 'TGVh43ag',
'First Name' => 'joe',
'Last Name' => 'schmoe',
);
$ch = curl_init();
// set referer:
curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/");
// This allows you to type google.com and not http://www.google.com
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch, CURLOPT_URL,"https://crm.zoho.com/crm/WebToLeadForm");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
curl_exec ($ch);
curl_close ($ch);
?>
I'm not sure if I have mentioned this yet or not but when I set the form action to
https://crm.zoho.com/crm/WebToLeadForm instead of a php processor script everything works smoothly.
Thanks again so much for your help guys.