Welcome Guest, Not a member yet? Register   Sign In
Help With Curl - Please!
#1

[eluser]Jay Logan[/eluser]
Basically, I can get this to work as a form on an HTML page. All I have to do is hit the POST button and it gets inserted into my 3rd party CRM. The problem is that the "Success Page is just some XML with the details of the insert.

Code:
&lt;?= form_open('http://crm.zoho.com/crm/private/xml/Leads/insertRecords') ?&gt;<br>
&lt;?= form_hidden('apikey', 'MYAPIKEY') ?&gt;<br>
&lt;?= form_hidden('xmlData', $lead_info) ?&gt;<br>
&lt;?= form_hidden('loginName', 'MYUSERNAME') ?&gt;<br>
&lt;?= form_submit('post', 'Post') ?&gt;<br>
&lt;?= form_close() ?&gt;

So I decided to try Curl for the first time and I'm using this code as it seems logically the most similar to my form.

Code:
$values = array('Market' => 'Atlanta', 'First Name' => 'John', 'Last Name' => 'Doe');
$lead_info = $this->array_to_xml('Leads', $values);
$post_fields = array('xmlData' => $lead_info, 'loginName' => 'MYUSERNAME', 'apikey' => 'MYAPIKEY');
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_URL, 'http://crm.zoho.com/crm/private/xml/Leads/insertRecords');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
$result = curl_exec($ch);
curl_close($ch);
return $result;

But it doesn't insert the data. It returns XML with an error saying API KEY is required. So I change to URL to http://crm.zoho.com/crm/private/xml/Lead...y=MYAPIKEY and now it just gives a generic error in the XML.

My question is do I need to setopt some more details that would make the processing script think the Curl is the same as the HTML form? And is there any way to see what all gets passes to the processing script during a successful post from the HTML form. Thanks.


Messages In This Thread
Help With Curl - Please! - by El Forum - 08-09-2009, 08:44 AM
Help With Curl - Please! - by El Forum - 08-09-2009, 11:48 AM
Help With Curl - Please! - by El Forum - 08-09-2009, 12:14 PM
Help With Curl - Please! - by El Forum - 08-09-2009, 12:28 PM
Help With Curl - Please! - by El Forum - 08-09-2009, 12:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB