dtbsezxw28056 2017-04-05 11:00
浏览 129

使用XML参数执行GET请求(PHP cURL)

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.

  • 写回答

1条回答 默认 最新

  • doutang2017 2017-04-05 11:02
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊