public function AddSubscriberToList($emailAddress, $listIDs, $subscriberKey = null)
    {
        $newSub = new ET_Subscriber;
        $newSub->authStub = $this;
        $lists = array();

        foreach ($listIDs as $key => $value) {
            $lists[] = array("ID" => $value);
        }

        //if (is_string($emailAddress)) {
        $newSub->props = array("EmailAddress" => $emailAddress, "Lists" => $lists);
        if ($subscriberKey != null) {
            $newSub->props['SubscriberKey']  = $subscriberKey;
        }

        // Try to add the subscriber
        $postResponse = $newSub->post();
        if ($postResponse->status == false) {
            // If the subscriber already exists in the account then we need to do an update.
            // Update Subscriber On List
            if ($postResponse->results[0]->ErrorCode == "12014") {
                $patchResponse = $newSub->patch();
                return $patchResponse;
            }
        }
        return $postResponse;
    }
public function AddSubscriberToList($emailAddress, $listIDs, $subscriberKey = null)
    {
        $newSub = new ET_Subscriber;
        $newSub->authStub = $this;
        $lists = array();

        foreach ($listIDs as $key => $value) {
            $lists[] = array("ID" => $value);
        }

        //if (is_string($emailAddress)) {
        $newSub->props = array("EmailAddress" => $emailAddress, "Lists" => $lists);
        if ($subscriberKey != null) {
            $newSub->props['SubscriberKey']  = $subscriberKey;
        }

        // Try to add the subscriber
        $postResponse = $newSub->post();
        if ($postResponse->status == false) {
            // If the subscriber already exists in the account then we need to do an update.
            // Update Subscriber On List
            if ($postResponse->results[0]->ErrorCode == "12014") {
                $patchResponse = $newSub->patch();
                return $patchResponse;
            }
        }
        return $postResponse;
    }
public function AddSubscriberToList ( $ emailAddress , $ listIDs , $ subscriberKey = null ) { $ newSub = new ET_Subscriber ; $ newSub -> authStub = $ this ; $ lists = array ( ) ; foreach ( $ listIDs as $ key => $ value ) { $ lists [ ] = array ( "ID" => $ value ) ; } //if (is_string($emailAddress)) { $ newSub -> props = array ( "EmailAddress" => $ emailAddress , "Lists" => $ lists ) ; if ( $ subscriberKey != null ) { $ newSub -> props [ 'SubscriberKey' ] = $ subscriberKey ; } // Try to add the subscriber $ postResponse = $ newSub -> post ( ) ; if ( $ postResponse -> status == false ) { // If the subscriber already exists in the account then we need to do an update. // Update Subscriber On List if ( $ postResponse -> results [ 0 ] -> ErrorCode == "12014" ) { $ patchResponse = $ newSub -> patch ( ) ; return $ patchResponse ; } } return $ postResponse ; }
Add subscriber to list.

@param string $emailAddress Email address of the subscriber
@param array $listIDs Array of list id to which the subscriber is added
@param string $subscriberKey Newly added subscriber key
@return mixed post or patch response object. If the subscriber already existing patch response is returned otherwise post response returned.
Add subscriber to list .