Updating subscriber fields through API

Discussion in 'General discussions' started by eggerda, Oct 3, 2019.

  1. eggerda

    eggerda Member

    Joined:
    Feb 9, 2019
    Messages:
    32
    Likes Received:
    1
    S.E:
    2020-02-09 05:21:21
    L.T:
    Regular
    L.C:
    1
    Hello! We have an API call to update a custom field value for a subscriber, and then another one (immediately after) to UNSUBSCRIBE them:

    $response = $endpoint->update($list['general']['list_uid'], $record['subscriber_uid'], array(
    'MOVE' => '2'

    $response = $endpoint->unsubscribe($list['general']['list_uid'], $record['subscriber_uid']);

    Is it possible to accomplish this with just ONE API call? For example, can I just use the "update" to change the subscribers STATUS as well? My programmer is tied up right now, so I have to make this change if possible.

    If this is possible, what would the STATUS field name be that I can use in the UPDATE call? And what value should it be to set the subscriber as unsubscribed?

    Thank you!

    Dan
     
  2. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,436
    Likes Received:
    2,427
    Maybe:
    PHP:
    $response $endpoint->update($list['general']['list_uid'], $record['subscriber_uid'], array(
    'MOVE' => '2',
    'details' => [ 'status' => 'unsubscribed' ]
     
  3. eggerda

    eggerda Member

    Joined:
    Feb 9, 2019
    Messages:
    32
    Likes Received:
    1
    S.E:
    2020-02-09 05:21:21
    L.T:
    Regular
    L.C:
    1
    Yep, this works perfectly. Thank you so much!
     
  4. eggerda

    eggerda Member

    Joined:
    Feb 9, 2019
    Messages:
    32
    Likes Received:
    1
    S.E:
    2020-02-09 05:21:21
    L.T:
    Regular
    L.C:
    1
    @twisted1919, or anybody else who has an answer... when I READ records from the API by custom field, is it possible to sort things by date added? I want to process the OLDEST records first...

    It's this API call specifically...

    // SEARCH BY custom field
    $response = $endpoint->searchByCustomFields('sh296mj4sddc4', array(
    'FNAME' => 'the fname',
    'LNAME' => ' the lname',
    ));
     
  5. ghimes

    ghimes New Member Staff Member Support Staff

    Joined:
    Feb 2, 2018
    Messages:
    22
    Likes Received:
    8
    Hello,
    Once you get the records from the API you can sort the array in PHP based on that 'date_added' column.
    Cosmin
     
  6. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,436
    Likes Received:
    2,427
    @eggerda - as @ghimes said, for now you will have to do it in your code, we don't have a flag for sorting in the api side.
     

Share This Page