Skip to content

http_build_query default separator not explicit #1

@sikjoy

Description

@sikjoy

require_once getcwd() .'/sites/all/vendor/piplcom/piplapis-php/src/piplapis/search.php';

$params = array(
'api_key' => 'redacted',
'first_name' => 'Test',
'middle_name' => '',
'last_name' => 'Test',
'city' => 'Beverly Hills',
'country' => 'US',
'state' => 'CA',
'phone' => '8885550123',
'email' => 'test@example.com',
);
$request = new PiplApi_SearchAPIRequest($params);
$request->send(FALSE);

results in the following exception:

PiplApi_SearchAPIError: The query does not contain any valid name/username/phone/email to search by in PiplApi_APIError::from_dict() (line 35 of vendor/piplcom/piplapis-php/src/piplapis/error.php).

I was able to fix the issue. See diff below:

diff --git a/src/piplapis/search.php b/src/piplapis/search.php
index c3266a9..c72c480 100644
--- a/src/piplapis/search.php
+++ b/src/piplapis/search.php
@@ -455,7 +455,7 @@ class PiplApi_SearchAPIRequest
'filter_records_by' => $this->_filter_records_by
);

  •    return self::$BASE_URL . http_build_query($query);
    
  •    return self::$BASE_URL . http_build_query($query, '', '&');
    

    }

    public function send($strict_validation=true)
    @@ -730,4 +730,4 @@ class PiplApi_SearchAPIError extends PiplApi_APIError
    // error.
    }

Apparently, my server was using '&' as the default http_build_query separator and this was causing problems with the API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions