コード例 #1
0
ファイル: li_aweber.php プロジェクト: AndyGCook/leadout
 /**
  * Uses the app's authorization code to fetch an access token
  *
  * @param String Authorization code from authorize app page
  */
 public static function getDataFromAweberID($string)
 {
     list($consumerKey, $consumerSecret, $requestToken, $tokenSecret, $verifier) = LI_AWeberAPI::_parseAweberID($string);
     if (!$verifier) {
         return null;
     }
     $aweber = new LI_AWeberAPI($consumerKey, $consumerSecret);
     $aweber->adapter->user->requestToken = $requestToken;
     $aweber->adapter->user->tokenSecret = $tokenSecret;
     $aweber->adapter->user->verifier = $verifier;
     list($accessToken, $accessSecret) = $aweber->getAccessToken();
     return array($consumerKey, $consumerSecret, $accessToken, $accessSecret);
 }
コード例 #2
0
 function li_ac_connect_to_api($auth_code)
 {
     try {
         $auth = LI_AWeberAPI::getDataFromAweberID($auth_code);
         list($consumerKey, $consumerSecret, $accessKey, $accessSecret) = $auth;
         if ($consumerKey) {
             $this->options['li_ac_ck'] = $consumerKey;
         }
         if ($consumerSecret) {
             $this->options['li_ac_cs'] = $consumerSecret;
         }
         if ($accessKey) {
             $this->options['li_ac_ak'] = $accessKey;
         }
         if ($accessSecret) {
             $this->options['li_ac_as'] = $accessSecret;
         }
         if (!$consumerKey && !$consumerSecret && !$accessKey && !$accessSecret) {
             return FALSE;
         }
         update_option($this->power_option_name, $this->options);
     } catch (LI_AWeberAPIException $exc) {
         /*print "<h3>AWeberAPIException:</h3>";
           print " <li> Type: $exc->type              <br>";
           print " <li> Msg : $exc->message           <br>";
           print " <li> Docs: $exc->documentation_url <br>";
           print "<hr>";*/
     }
 }
コード例 #3
0
ファイル: aweber-connect.php プロジェクト: AndyGCook/leadout
 /**
  * Adds a subcsriber to a specific list
  *
  * @param   string
  * @param   string
  * @param   string
  * @param   string
  * @param   string
  * @return  int/bool
  */
 function push_contact_to_list($list_id = '', $email = '', $first_name = '', $last_name = '', $phone = '')
 {
     if (isset($this->options['li_ac_ck']) && $this->options['li_ac_ck'] && $list_id) {
         try {
             $aweber = new LI_AWeberAPI($this->options['li_ac_ck'], $this->options['li_ac_cs']);
             $account = $aweber->getAccount($this->options['li_ac_ak'], $this->options['li_ac_as']);
             $list_url = "/accounts/" . $account->id . "/lists/" . $list_id;
             //Check if custom Field Exists
             $list_custom_fields_url = "/accounts/" . $account->id . "/lists/" . $list_id . "/custom_fields";
             $list_custom_fields = $account->loadFromUrl($list_custom_fields_url);
             $params = array('email' => $email, 'name' => $first_name . $last_name);
             if (count($list_custom_fields->data['entries'])) {
                 foreach ($list_custom_fields->data['entries'] as $entry) {
                     if ($entry['name'] == 'phone') {
                         $params['custom_fields'] = array('phone' => $phone);
                         break;
                     }
                 }
             }
             $list = $account->loadFromUrl($list_url);
             $subscribers = $list->subscribers;
             $subscribers->create($params);
             return TRUE;
         } catch (AWeberAPIException $exc) {
         }
     }
     return FALSE;
 }