Hi all
We are developing a synchronization interface from our old email marketing solution into on premise installed mautic. What this interface does is very simple, it just takes all our contacts from the old software using its API and imports into mautic using the mautic API.
Why haven’t we used download and import files? Because the migration to mautic will not be made quickly, and we want every new contact signing up to the old software to be migrated to mautic. At some point in time all our sign up forms will be redirected to mautic and this interface will be shut down along with the old software.
Now that the context is clear, here is our problem. One of the custom fields of the contact is “subscription channel”. This is quite important for us since it identified how the contact initially came into our database. We want this field values to be migrated from the old solution for every contact, but as well we want the field to be a “select” since then it will be shown in forms and values cannot be entered freely by anyone.
In a specific section of the sync interface code when processing a contact, we want to check if the subscription channel value already exists in the select list of the custom field, and if not we want to create it. We already solved the if value exists in select list part, but cannot edit the select list to add a new value to it.
This is the code we are using.
$data = array(“properties” => array(“list” => array(array(“label” => $subscriptionChannel, “value” => $subscriptionChannel))));
debugging it…
Array
(
[properties] => Array
(
-
=> Array
(
[0] => Array
(
[label] => FacebookPago-prueba
[value] => FacebookPago-prueba
)
)
)
)
Then we call this
$api->edit($id,$data,$createIfNotFound);
where $id=65 (the id of the custom field), $data is what shown above and $createIFNotFound=false
$api is instantiated to be an $api object which $context is contactFields
After calling the api we get this error
Array
(
[error] => Array
(
[message] => signature_invalid
)
We also tested other “edit” operations but now on “properties”. For example editing “label” parameter of the field went well… Why does this happen? Is any problem processing parameters which are arrays?
At this point we do not know if the error is caused by the way we are creating the $data argument or there is a bug here in OAuth.php file of the php api client.
private function normalizeParameters($parameters, $encode = false, $returnarray = false, $normalized = array(), $key = ‘’)
{
//Sort by key
ksort($parameters);
foreach ($parameters as $k => $v) {
if (is_array($v)) {
$normalized = $this->normalizeParameters($v, $encode, true, $normalized, $k);
} else {
if ($key) {
//Multidimensional array; using foo=baz&foo=bar rather than foo[bar]=baz&foo[baz]=bar as this is
//what the server expects when creating the signature
$k = $key;
}
if ($encode) {
$normalized[] = $this->encode($k).'='.$this->encode($v);
} else {
$normalized[] = $k.'='.$v;
}
}
}
return $returnarray ? $normalized : implode('&', $normalized);
}
Any help will be truly appreciated!
Thanks[code] => 401
)
)
We also tested other “edit” operations but now on “properties”. For example editing “label” parameter of the field went well… Why does this happen? Is any problem processing parameters which are arrays?
At this point we do not know if the error is caused by the way we are creating the $data argument or there is a bug here in OAuth.php file of the php api client.
private function normalizeParameters($parameters, $encode = false, $returnarray = false, $normalized = array(), $key = ‘’)
{
//Sort by key
ksort($parameters);
foreach ($parameters as $k => $v) {
if (is_array($v)) {
$normalized = $this->normalizeParameters($v, $encode, true, $normalized, $k);
} else {
if ($key) {
//Multidimensional array; using foo=baz&foo=bar rather than foo[bar]=baz&foo[baz]=bar as this is
//what the server expects when creating the signature
$k = $key;
}
if ($encode) {
$normalized[] = $this->encode($k).’=’.$this->encode($v);
} else {
$normalized[] = $k.’=’.$v;
}
}
}
return $returnarray ? $normalized : implode(’&’, $normalized);
}
Any help will be truly appreciated!
Thanks