How to replace aweber oauth api 1.0 to oauth 2.0

149 views Asked by At

One of my website is using Aweber deprecated API (https://github.com/aweber/AWeber-API-PHP-Library), it was working fine previously but stopped, the implementation of this API has been done by another developer, now this website is handled by me and I never have worked with Aweber, may anyone help me to replace OAuth 1.0 to OAuth 2.0.

the error users receive after sign up is this.

error

this is the YII register controller which sends welcome emails

 if ($model->load(\Yii::$app->request->post()) && $model->register()) {
       $this->trigger(self::EVENT_AFTER_REGISTER, $event);

        $consumerKey    = 'XXXXXXXXXXXXXXXXXXXXXXXX';
        $consumerSecret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX';

        $accessKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
        $accessSecret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
        $list_id = '3857937';
            $aweber = new \AWeberAPI($consumerKey, $consumerSecret);
        try {
            $account = $aweber->getAccount($accessKey, $accessSecret);
            $account_id = $account->id;              
            $listURL = "/accounts/{$account_id}/lists/{$list_id}";
            $list = $account->loadFromUrl($listURL);

            $params = array(
                'email' => $model->email,
                'ad_tracking' => 'My_Web_Form_3',
                'name' => $model->username
            );

            $subscribers = $list->subscribers;
            $new_subscriber = $subscribers->create($params);

        } catch(AWeberAPIException $exc) {

        }           
        return $this->render('message', [
            'title'  => \Yii::t('user', 'Your account has been created'),
            'module' => $this->module,
        ]);
    }

    return $this->render('register_w', [
        'model'  => $model,
        'module' => $this->module,
    ]);
}
0

There are 0 answers