How to get lists from aweber based on access keys stored in database

223 Views Asked by At

I am trying to get the lists details from aweber account i can get all lists by hard code access keys but what if i want to fetch from database.

here is my code:

    $consumerKey    = env('consumerKey');
    $consumerSecret = env('consumerSecret');

    $user_id = \Illuminate\Support\Facades\Auth::user();
          $keys = \Illuminate\Support\Facades  \ DB::table('access_keys')->where('user_id','=', $user_id)->value('accessTokenKey','accessTokenSecret');

    $accessKey      = $keys;
    $accessSecret   = $keys

I am having invalid accesstoken from this query and i have saved accesskey and accesssecret into my database. when i hard code i can get all the lists but i want to fetch from database:

Any help would be appreciated!

1

There are 1 best solutions below

0
jagjeet On

First get Aweber API code from git:- https://github.com/aweber/AWeber-API-PHP-Library

To get lists from Aweber account , you need to follow below details:-

require_once('aweber_api/aweber_api.php');
$consumerKey    = "YOUR  CONSUMER KEY";
$consumerSecret = "YOUR CONSUMER SECRET";
$aweber = new AWeberAPI($consumerKey, $consumerSecret);
$accessToken = 'Access token for customer account';
$accessTokenSecret = 'access token secret for customer account';

$account = $aweber->getAccount($accessToken, $accessTokenSecret);

if($account){
      foreach($account->lists as $offset => $list) {
           echo $list->name;
           echo $list->id;
      }
}