在Zoho API CRM上没有得到任何响应


Getting no response on Zoho API CRM

我正在尝试使用getSearchRecordsByPDC方法,可以在这里找到https://www.zoho.com/crm/help/api/getsearchrecordsbypdc.html#Request_URL

我有这个代码:

private $token = '1234567890abcdefg';
public $responseType = 'xml';
 public function getSearchRecordsByPDC($searchValue,$searchColumn='email')
 {
 $url = "https://crm.zoho.com/crm/private/".$this->responseType."/Leads/getSearchRecordsByPDC?newFormat=1&authtoken=".$this->token."&scope=crmapi&selectColumns=Leads(First Name,Lead Source,Phone,Mobile,Website,Lead Status,Description,Last Name,Website,Email,Lead Owner)&searchColumn=$searchColumn&searchValue=$searchValue";
 $result = $this->curlRequest($url);
 return $result;
 }
 public function curlRequest($url)
 {
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 $output = curl_exec($ch);
 curl_close($ch);
 return $output;
 }
$data = $zoho->getSearchRecordsByPDC('my_email@gmail.com');
print_r($data);

我只是发布了一些代码片段,以免显得太长。

运行此代码时。我没有得到任何响应,甚至是错误消息或其他什么,就像我得到了一个空白响应,没有xml响应或其他什么。但是,当我尝试将$url变量输出复制并粘贴到web浏览器中时,我会得到响应,并且这些响应是有效的。

这个怎么了?我们将非常感谢您的帮助!谢谢

看起来你把OOP和过程代码混在了一起。试试这个:

class Zoho {
    private $token = '1234567890abcdefg';
    public $responseType = 'xml';
    public function getSearchRecordsByPDC($searchValue,$searchColumn='email')
    {
        $url = "https://crm.zoho.com/crm/private/".$this->responseType."/Leads/getSearchRecordsByPDC?newFormat=1&authtoken=".$this->token."&scope=crmapi&selectColumns=Leads(First Name,Lead Source,Phone,Mobile,Website,Lead Status,Description,Last Name,Website,Email,Lead Owner)&searchColumn=$searchColumn&searchValue=$searchValue";
        $result = $this->curlRequest($url);
        return $result;
    }
    public function curlRequest($url)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $output = curl_exec($ch);
        curl_close($ch);
        return $output;
    }
}
$zoho = new Zoho;
$data = $zoho->getSearchRecordsByPDC('my_email@gmail.com');
print_r($data);