Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

The query parameter email is not supported. #148

Open
FilipQL opened this issue Aug 25, 2017 · 2 comments
Open

The query parameter email is not supported. #148

FilipQL opened this issue Aug 25, 2017 · 2 comments
Assignees

Comments

@FilipQL
Copy link

FilipQL commented Aug 25, 2017

Hello,

I am using your php-sdk with Laravel 4.2. I followed the documentation and the code examples, but I'm getting the following error:

Error Getting Contact By Email Address
Array
(
    [0] => stdClass Object
        (
            [error_key] => query.param.invalid
            [error_message] => The query parameter email is not supported.
        )

)

Here is the code:

<?php

use Ctct\ConstantContact;
use Ctct\Components\Contacts\Contact;
use Ctct\Components\Contacts\ContactList;
use Ctct\Components\Contacts\EmailAddress;
use Ctct\Exceptions\CtctException;

class NewsletterController extends \BaseController {

   protected $key = '***...***';
   protected $token = '***...***';
   protected $list_id = '***...***';
   protected $cc;

   public function __construct()
   {
      $this->cc = new ConstantContact($this->key);
   }

   public function subscribe()
   {
      . . .

      $action = "Getting Contact By Email Address";

      try {
         // THIS IS WHERE IT FAILS:
         $response = $this->cc->contactService
            ->getContactsFromList($this->token, $this->list_id, ["email" => Input::get('email')]);

       ...

The problem is with the third param: ["email" => Input::get('email')] - but not sure why because it's as stated in the PHPDoc of the getContactsFromList method:

/**
 * Get all contacts from an individual list
 * @param string $accessToken - Constant Contact OAuth2 access token
 * @param string $listId - {@link ContactList} id to retrieve contacts for
 * @param array $params - associative array of query parameters and values to append to the request.
 *      Allowed parameters include:
 *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
 *      modified_since - ISO-8601 formatted timestamp.
 *      next - the next link returned from a previous paginated call. May only be used by itself.
 *      email - full email address string to restrict results by
 *      status - a contact status to filter results by. Must be one of ACTIVE, OPTOUT, REMOVED, UNCONFIRMED.
 * @return ResultSet
 * @throws CtctException
 */
public function getContactsFromList($accessToken, $listId, Array $params = array()) {
TheGravee added a commit to TheGravee/php-sdk that referenced this issue Aug 29, 2017
@TheGravee TheGravee self-assigned this Aug 30, 2017
@FilipQL
Copy link
Author

FilipQL commented Aug 30, 2017

@TheGravee Please note that I'm using php-sdk 3.0.0-alpha because I need Guzzle 6 for the other packages/dependencies (as stated here by other users: #113).

@TheGravee
Copy link

TheGravee commented Aug 30, 2017

@FilipQL So the root of the issue is a documentation error. The GetContactsByList method does not accept an email or status parameter, and should not show as such in the SDK. If you are getting all contacts on a specific list ID, there is no reason to specify an email address. If you are needing to get a contact by email address, you should be using getContacts which will take that as a parameter.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants