: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
defined('ABSPATH') || exit;
class Builder_Optin_Service_GetResponse extends Builder_Optin_Service {
public static function get_id():string {
public static function get_label():string {
return __('GetResponse', 'themify');
public static function get_settings():array {
$lists = self::get_lists();
'label' => __('Campaign (List)', 'themify'),
'class' => 'tb_field_error_msg',
public function get_options():array {//backward for fw 7.5
return self::get_settings();
public static function get_global_options():array {
'id' => 'getresponse_key',
'label' => __('GetResponse API Key', 'themify'),
'description' => sprintf(__('<a href="%s" target="_blank">Get an API key</a>', 'themify'), 'https://app.getresponse.com/api'),
private static function request($request, $method = 'GET', $args = array()) {
$api_key = self::get_api_key();
$url = 'https://api.getresponse.com/v3/';
'X-Auth-Token' => 'api-key ' . $api_key,
'Content-Type' => 'application/json'
$response = wp_remote_request($url, $args);
if (is_wp_error($response)) {
return json_decode(wp_remote_retrieve_body($response), true);
protected static function request_list() {
if (is_wp_error(( $data = self::request('campaigns')))) {
if (!empty($data) && is_array($data)) {
$lists[$v['campaignId']] = $v['name'];
return new WP_Error('list_error', __('Error retrieving campaigns.', 'themify'));
* Gets data from module and validates API key
public static function validate_data(array $fields_args):string {
return isset($fields_args['gr_list']) ? '' :__('No list is selected.', 'themify');
* @doc: https://apidocs.getresponse.com/v3/resources/contacts
public static function subscribe(array $args) {
$sub = self::request('contacts', 'POST', array(
'body' => json_encode(array(
'email' => $args['email'],
'campaignId' => $args['gr_list']
'name' => sprintf('%s %s', $args['fname'], $args['lname']),
elseif (isset($sub['httpStatus'], $sub['message'])) {
return new WP_Error('error', $sub['message']);