将SOSL与REST API与PHP一起使用以从Salesforce获取数据数据

时间:2017-07-11 07:26:07

标签: php rest api syntax salesforce

我需要通过REST API从Salesforce的潜在客户和联系人那里获取数据。在我看到Salesforce不支持 UNION 时,我们需要使用SOSL来获取数据。

为此我使用下面的代码

    $url = $instance_url. '/services/data/v37.0/search/?q= FIND {rohit} IN ALL FIELDS RETURNING Lead(email), Contact(email)';
    $urlcurl = curl_init($url);
    curl_setopt($urlcurl, CURLOPT_HEADER, false);
    curl_setopt($urlcurl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($urlcurl, CURLOPT_HTTPGET, 1);
    curl_setopt($urlcurl, CURLOPT_HTTPHEADER,
    array("Authorization: OAuth $access_token"));
    curl_setopt($urlcurl, CURLOPT_SSL_VERIFYPEER, false);
    $urljson_response = curl_exec($urlcurl);
    $status = curl_getinfo($urlcurl, CURLINFO_HTTP_CODE);
    if ( $status != 200 ) {
        die("Error: call to URL failed with status $status, response $urljson_response, curl_error " . curl_error($urlcurl) . ", curl_errno " . curl_errno($urlcurl));
    }
    curl_close($urlcurl);
    return json_decode($urljson_response); 

但是它会返回一个像

这样的回复
Error: call to URL failed with status 400, response , curl_error , curl_errno 0

我怎样才能做到这一点?

0 个答案:

没有答案