0

我正在尝试使用可在此处找到的 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变量输出复制并粘贴到我的网络浏览器中时,我会收到响应,并且这些响应是有效的。

这有什么问题?对你的帮助表示感谢!谢谢!

4

1 回答 1

0

看起来您正在混淆 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);
于 2014-07-15T13:35:34.217 回答