Как получить настраиваемое поле для конкретной кампании (списка) через API в GetResponse - PullRequest
0 голосов
/ 11 октября 2018

Я получаю весь пользовательский список, но я хочу получить пользовательский список для конкретной кампании.Здесь getCustomField возвращает список пользовательских полей, но когда я пытаюсь передать его с идентификатором кампании (e.g $this->call('custom-fields/'.$custom_id, 'GET')), в ответе говорится, что нет ресурса с HTTP-кодом 401 * 1006.*

class GetResponse
{
    private $api_key;
    private $api_url = 'https://api.getresponse.com/v3';

    public function __construct($api_key, $api_url = null)
    {
        $this->api_key = $api_key;
        if (!empty($api_url)) {
            $this->api_url = $api_url;
        }
    }

    public function getCustomField($custom_id)
    {
        return $this->call('custom-fields/', 'GET');
    }

   private function call()
    {
        if (empty($api_method)) {
            return (object)array(
                'httpStatus' => '400',
                'code' => '1010',
                'codeDescription' => 'Error in external resources',
                'message' => 'Invalid api method'
            );
        }
        $params = json_encode($params);
        $url = $this->api_url . '/' . $api_method;
        $options = array(
            CURLOPT_URL => $url,
            CURLOPT_ENCODING => 'gzip,deflate',
            CURLOPT_FRESH_CONNECT => 1,
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_TIMEOUT => $this->timeout,
            CURLOPT_HEADER => false,
            CURLOPT_USERAGENT => 'PHP GetResponse client 0.0.2',
            CURLOPT_HTTPHEADER => array('X-Auth-Token: api-key ' . $this->api_key, 'Content-Type: application/json')
        );
        if (!empty($this->enterprise_domain)) {
            $options[CURLOPT_HTTPHEADER][] = 'X-Domain: ' . $this->enterprise_domain;
        }
        if (!empty($this->app_id)) {
            $options[CURLOPT_HTTPHEADER][] = 'X-APP-ID: ' . $this->app_id;
        }
        if ($http_method == 'POST') {
            $options[CURLOPT_POST] = 1;
            $options[CURLOPT_POSTFIELDS] = $params;
        } else if ($http_method == 'DELETE') {
            $options[CURLOPT_CUSTOMREQUEST] = 'DELETE';
        }
        $curl = curl_init();
        curl_setopt_array($curl, $options);
        $response = json_decode(curl_exec($curl));
        $this->http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        curl_close($curl);
        $response->httpStatus = $this->http_status;
        return $response;
    }
}
...