BigCommerce - Hosted Ecommerce Software by Interspire

Interspire Forum

 
Go Back   Interspire Forum > Interspire Email Marketer Community Forum > Customization and Integration

Reply
 
Thread Tools Display Modes
  #1  
Old 07-27-2009, 03:28 PM
differenthink + differenthink is offline
Interspire Customer
 
Join Date: Jul 2009
Posts: 8
Question XML API, update subscriber custom fields

Hi,

Everybody agree that IEM is missing one of the major function, the UPDATE one !!!!

So i decided to try to implement it myself with the help of :
http://blog.affinitywebsolutions.co....other-systems/

I m succesfull on updating the email adress of a subscriber, but i m stuck with the customs fields.
I tried to do that (i created a UpdateSubscriberCustomField) :

require(SENDSTUDIO_API_DIRECTORY . '/customfields.php');
$customfields_api = new CustomFields_API();
$subscriber_customfields = (isset($function_params['customfields']['item'])) ? $function_params['customfields']['item'] : $function_params['customfields'];

foreach ($subscriber_customfields as $k => $details) {
$handlerObject->UpdateSubscriberCustomField($params['subscriber_id'], $details['fieldid'], $details['value']);
}

But it doesn t seems to well retrieve my custom field, and i don t know why...

Any idea ?

If Interspire is reading to this thread, WHY ARE YOU NOT CONSIDERING GIVING THIS UPDATE OPTION AS DEFAULT... it will be a 1h job for you tech guys !!!!
Reply With Quote
  #2  
Old 07-28-2009, 11:18 AM
julienmarie + julienmarie is offline
Interspire Customer
 
Join Date: Jul 2009
Posts: 2
Default

Hi,

I've just integrated this function yesterday.
It provides an unified way to update the email address and every customfield you need.
The XML you send should be like this :

toto@toto.com
1
54 // I think we can remove this one and use the $subid var in the code... need to test it
New Email Address // just in case you want to change the email address

1somevalue
1somevalue



And call the subscribers request type and update_user request method
Here is my code, on the switch/case zone of the xml.php file :


case 'update_user' :
$db = IEM::getDatabase();
$db->StartTransaction();
$params = array();
$params['emailaddress'] = (isset($function_params['emailaddress'])) ? $function_params['emailaddress'] : false;
$params['mailinglist'] = (isset($function_params['mailinglist'])) ? $function_params['mailinglist'] : false;
$params['userid'] = (isset($function_params['mailinglist'])) ? $function_params['userid'] : false;
// check if they are on the list already.
$subid = call_user_func_array(array($handlerObject, 'IsSubscriberOnList'), $params);
if (!$subid) {
SendResponse(false, '');
exit;
}
$subsid = Array();
$subsid[0] = $params['userid'];
$subapi = new Subscribers_API();
if (isset($function_params['newemailaddress'])) {
$updater = $subapi->UpdateEmailAddress($subid, $function_params['newemailaddress']);
}
require(SENDSTUDIO_API_DIRECTORY . '/customfields.php');
$customfields_api = new CustomFields_API();
if (isset($function_params['customfields'])) {
$subscriber_customfields = $function_params['customfields'];
foreach ($subscriber_customfields as $k => $details) {
$loaded = $customfields_api->Load($details['fieldid']);
if (!$loaded) {
$db->RollbackTransaction();
SendResponse(false, "Unable to load field id '" . $details['fieldid'] . "'");
exit;
}
// See if specific custom fields need data transformation
switch ($customfields_api->fieldtype) {
// Custom fields that require multiple values need to be converted to array
case 'checkbox':
if (!is_array($details['value'])) {
$details['value'] = array($details['value']);
}
break;

// All other custom fields
default:

break;
}
$valid_value = $customfields_api->ValidData($details['value']);
if (!$valid_value) {
$db->RollbackTransaction();
SendResponse(false, "The data provided for field '" . $customfields_api->GetFieldName() . "' is invalid (you provided '" . $details['value'] . "')");
exit;
}
$updater2 = $subapi->SaveSubscriberCustomField($subid, $details['fieldid'], $details['value']);
if ($updater2 != 1) {
SendResponse(false, 'Erreur de modification de champs '.$subid." - ".$details['fieldid']." - ".$details['value']. " = ".$updater2);
}
}
}
$db->CommitTransaction();
SendResponse(true);
break;

Hope that helps !


Julien Marie
yesornow.com
Reply With Quote
  #3  
Old 07-28-2009, 11:19 AM
julienmarie + julienmarie is offline
Interspire Customer
 
Join Date: Jul 2009
Posts: 2
Default

(the XML has been stripped out !)
Reply With Quote
  #4  
Old 07-30-2009, 04:38 PM
differenthink + differenthink is offline
Interspire Customer
 
Join Date: Jul 2009
Posts: 8
Default

Thanks for your help.
I did some modification to adapt it to my desire, and it works.

good job.
Reply With Quote
  #5  
Old 07-31-2009, 10:05 PM
loze + loze is offline
Interspire Customer
 
Join Date: Sep 2008
Posts: 7
Default

... Nevermind.

Last edited by loze; 08-01-2009 at 07:18 AM..
Reply With Quote
  #6  
Old 10-22-2009, 11:50 AM
lochorui + lochorui is offline
Interspire Customer
 
Join Date: Jun 2008
Posts: 7
Default Missing XML!

Hi Julie:

Thanks for the code. I´m trying to implement it, but i always receive the same answer:

Status is
Error is

Maybe i am not using a correct XML. Could you send me the correct structure please?

My XML is like this:


myuser f94de11661ec1ac5ff0fd2bfd5d51d65b8sy9rta
subscribers
update_user

email@email.com
4
247
html
yes


168
name


15
10000



';

Thank you!

best regards,

Lukas.
Reply With Quote
  #7  
Old 10-22-2009, 11:56 AM
lochorui + lochorui is offline
Interspire Customer
 
Join Date: Jun 2008
Posts: 7
Default

It happend to me the same. the XML has gone away!

i wanted to add:

emailaddress: email@email.com
userid: 4 (is this the user of the system or a subscriber?)
mailinglist: 247
format: html
confirmed: yes
custom fields:
item: fieldid: value
item: fieldid: value

thanks again!!
Reply With Quote
  #8  
Old 01-28-2010, 10:25 PM
trioviagroup + trioviagroup is offline
Interspire Customer
 
Join Date: Nov 2009
Posts: 42
Default

So here we are 6 months later from the last post... I'm beginning to wonder if the IEM guys are even reading this...

I can't imagine it would be a major undertaking for them?? anyone have a solution yet?

I'm a little confused by the code below... what file does that go in?
Reply With Quote
  #9  
Old 02-21-2010, 08:21 PM
jeffrey + jeffrey is offline
Interspire Customer
 
Join Date: Oct 2008
Posts: 2
Default great this worked out fine

This worked out fine for me. I can update custom fields now Thanks
Reply With Quote
  #10  
Old 02-24-2010, 03:26 PM
myrinx
Guest
 
Posts: n/a
Default Columbus egg

Hi All,

I've managed to make the so desired updateSubscriber XML API call. It's based on the addSubscriber and uses the UpdateEmail clause made in this thread.

My problem with the previous suggestion is that only 1 custom field at a time was being updated (v6 of interspire).

The new api Command updates everything you supply in the command call.

Anyone interested, please let me know!

Thanks,
myrinx
Reply With Quote
Reply

Tags
xml api edit update

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump