subscribe users who register in another application

Questions about Version 3 phpList features (the answer is probably 'Yes!')
Forum rules
Please help the volunteers to help you by supplying the version of phpList you are using, browser & version and if possible, a link to your phpList installation.

subscribe users who register in another application

Postby jimlongo » 1:44am, Fri 07 Mar, 2014

I have a couple of systems and I'm trying to think of a way to tie them together a bit.

I have an online store that uses osCommerce.
Users who open an account there get email confirmations and such from the osCommerce installation. It's confusing to many of them that they don't also get broadcast emails from phpList. No matter how many places and times I instruct them to also register for the mailing list, it will get missed.

What I wish is that there was a way that new accounts opened on the osCommerce app would automatically subscribe to phpList. I would still require them to confirm the phpList subscription, so they wouldn't be subscribed without consent.

Anyone have any ideas on how I could accomplish this?

Thanks.
jimlongo
PL Geek
 
Posts: 88
Joined: 10:10pm, Tue 15 May, 2007

Re: subscribe users who register in another application

Postby jimlongo » 10:34pm, Sat 08 Mar, 2014

I'm looking into the restapi and it might work for me, except for the fact you need to be logged in to run anything.

I think i'm going to try this approach.
When the user submits their registration data to osCommerce, I will take the email and

->directly query the phpList db to
check if the email already exists
find the last id
add the user email
add the list(s)
mark confirmed.

Feel free to comment if you have a better idea.
jimlongo
PL Geek
 
Posts: 88
Joined: 10:10pm, Tue 15 May, 2007

Re: subscribe users who register in another application

Postby jimlongo » 10:52pm, Sat 08 Mar, 2014

Just came across this . . . viewtopic.php?f=7&t=5009&hilit=adding+user+to+database+confirmation and although it's fairly old it might offer some ideas.
jimlongo
PL Geek
 
Posts: 88
Joined: 10:10pm, Tue 15 May, 2007

Re: subscribe users who register in another application

Postby duncanc » 10:23am, Sun 09 Mar, 2014

I would still require them to confirm the phpList subscription, so they wouldn't be subscribed without consent.

Your approach isn't going to make phplist send the confirmation email. If you really want to do that then you will need to mimic submitting a subscribe page, using curl, so that phplist treats it as a real subscription.
I'm looking into the restapi and it might work for me, except for the fact you need to be logged in to run anything.

You might be misunderstanding how the restapi works. In your OS commerce code you would make calls to the API. The first API method that you need to call is to 'login' to phplist with an admin/password. After that you make calls to add a user, etc.
duncanc
Moderator
 
Posts: 2440
Joined: 6:34am, Sat 08 May, 2010
Location: London

Re: subscribe users who register in another application

Postby jimlongo » 10:36pm, Sun 09 Mar, 2014

duncanc wrote:
I'm looking into the restapi and it might work for me, except for the fact you need to be logged in to run anything.

You might be misunderstanding how the restapi works. In your OS commerce code you would make calls to the API. The first API method that you need to call is to 'login' to phplist with an admin/password. After that you make calls to add a user, etc.


It sounds promising if only I could login, to get started.
Here's my rest_test.php file, all it has is the method to login and getLists, when I run this I get nothing . . .
Code: Select all
<?php
/**
 * Class to communicate with phpList via API REST
 *
 **/
class phpList_RESTAPI_Test {

    private $session = null;
    private $url = 'http://mydomain.com/list/plugins/restapi/restapi.php';

    function __construct($url) {
        $this->url = $url;
    }

    private function setSessionID($sid){
        $this->session = $sid;
    }

    public function getSessionID(){
        return $this->session;
    }

    /************************************************************
     * Administrators Operation
     ************************************************************/

    /**
     * @param $loginname
     * @param $password
     * @return mixed
     */
    public function login( $login, $password ) {

        //Post Data
        $post_params = array(
            'login' => $login,
            'password' => $password
        );

        $result = $this->callAPI( 'login', $post_params);

        if ( $result->status == 'success' ) {
            $this->setSessionID( $result->data );
            return $result;
        }

        return $result;
    }

    /************************************************************
     * Lists
     ************************************************************/
    public function listsGet( ) {

        //Post Data
        $post_params = array(
        );

        $result = $this->callAPI( 'listsGet', $post_params);

        return $result;
    }



    /************************************************************
     * Remote Requests via cUrl or other
     ************************************************************/

    private function callAPI($command, $post_params, $no_decode=false ) {

        $post_params['cmd'] = $command;

        $post_params = http_build_query($post_params);

        $c = curl_init();
        curl_setopt($c, CURLOPT_URL,            $this->url );
        curl_setopt($c, CURLOPT_HEADER,         0);
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($c, CURLOPT_POST,           1);
        curl_setopt($c, CURLOPT_POSTFIELDS,     $post_params);
        curl_setopt($c, CURLOPT_COOKIEFILE,     $GLOBALS['tmpdir'].'/phpList_RESTAPI_Helper_cookiejar.txt');
        curl_setopt($c, CURLOPT_COOKIEJAR,      $GLOBALS['tmpdir'].'/phpList_RESTAPI_Helper_cookiejar.txt');
        curl_setopt($c, CURLOPT_HTTPHEADER,     array( 'Connection: Keep-Alive', 'Keep-Alive: 60' ));

        $result = curl_exec($c);

        if ( !$no_decode ) $result = json_decode($result);

        return $result;
    }
}

jimlongo
PL Geek
 
Posts: 88
Joined: 10:10pm, Tue 15 May, 2007


Return to Does phpList do this?

Who is online

Users browsing this forum: No registered users and 1 guest

cron