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

Catchable fatal error: Argument 1 must be of the type array, string given #145

Open
epilektric opened this issue Apr 12, 2017 · 1 comment

Comments

@epilektric
Copy link

Here is the full PHP error:

Catchable fatal error: Argument 1 passed to Ctct\Components\Activities\ActivityError::create() must be of the type array, string given, called in Ctct\Components\Activities\Activity.php on line 47 and defined in Ctct\Components\Activities\ActivityError.php on line 24

The API responds with something like the following:

array(10) { 
	["id"]=> string(36) "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 
	["type"]=> string(12) "ADD_CONTACTS" 
	["status"]=> string(8) "COMPLETE" 
	["errors"]=> array(2) { 
		[0]=> string(23) "Line 355: Invalid email" 
		[1]=> string(24) "Line 1068: Invalid email" 
	} 
	["file_name"]=> string(30) "default_list.txt" 
	["start_date"]=> string(24) "2017-04-11T13:55:30.000Z" 
	["finish_date"]=> string(24) "2017-04-11T13:55:41.000Z" 
	["created_date"]=> string(24) "2017-04-11T13:55:25.000Z" 
	["error_count"]=> int(50) 
	["contact_count"]=> int(1445) 
} 

But ActivityError::create() is expecting something like this:

array(10) { 
	["id"]=> string(36) "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 
	["type"]=> string(12) "ADD_CONTACTS" 
	["status"]=> string(8) "COMPLETE" 
	["errors"]=> array(2) { 
		[0]=> array(2) {
			["line_number"]=> int(355)
			["message"]=> string(13) "Invalid Email"
		}
		[1]=> array(2) {
			["line_number"]=> int(1068)
			["message"]=> string(13) "Invalid Email"
		}
	} 
	["file_name"]=> string(30) "default_list.txt" 
	["start_date"]=> string(24) "2017-04-11T13:55:30.000Z" 
	["finish_date"]=> string(24) "2017-04-11T13:55:41.000Z" 
	["created_date"]=> string(24) "2017-04-11T13:55:25.000Z" 
	["error_count"]=> int(50) 
	["contact_count"]=> int(1445) 
} 
@gmanewing
Copy link

gmanewing commented Jun 19, 2018

I know this is an old issue, but for those of us still searching for support, I found the following:

Quote:
After looking into this, it looks like the problem here is a bug that we introduced into the sample code for how that last parameter is being sent. The proper formatting is as follows:

$returnContact = $cc->contactService->addContact(ACCESS_TOKEN, $contact, array("action_by" => "ACTION_BY_OWNER")); //or "ACTION_BY_VISTOR"

Sincerely,
Elijah G.
API Support Engineer
End Quote

Look for $returnContact and replace as necessary.

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