-2

I'm trying to implement this API method and sending a GET request using PHP cURL.

Here is my code:

    $url = 'https://crm.zoho.com/crm/private/xml/'.$module.'/'.$method.'?authtoken='.config('app.ZOHO_KEY').'&scope=crmapi&newFormat=1&id='.$record_id.'&xmlData='.$XML_data;
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_exec($ch);

The URL computes to this:

https://crm.zoho.com/crm/private/xml/Contacts/updateRecords?authtoken=XXXX&scope=crmapi&newFormat=1&id=2410575000000139003&xmlData= <Contacts> <row no="1"> <FL val="Email Opt Out">true</FL> </row> </Contacts>

However, the request fails. I have tried str_replace(' ', '%20', $url) but this does not resolve the issue.

Adeel Ahmad
  • 1,033
  • 1
  • 11
  • 24

1 Answers1

0

I have tried str_replace(' ', '%20', $url)

You do this wrong. Proper tool for the task is urlencode()

EDIT

You should refactor your code and sent this data via regular POST request, which is exactly what is it for.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141