2013-03-13 68 views
0

我在https://labs.aweber.com/apps上創建了一個應用程序,並在他們的github上下載了php代碼https://github.com/aweber/AWeber-API-PHP-Library。我已閱讀他們的文檔,但不是很清楚。我不知道如何開始或先做什麼。我只是一個初學者,我從來沒有製作過應用程序。如何在Aweber中創建應用程序?

我試着先在我的頁面上創建PHP腳本,希望在提交表單時能夠滿足所需的功能,但沒有任何事情發生。我聯繫他們的支持,但他們建議做一個應用程序,使其正常工作。

網頁表單提交流程就像這樣。在主頁上,用戶可以輸入姓名,電子郵件,電話,並且有兩個電臺選項供您選擇,當您選擇一個電臺時,它將重定向到另一個頁面並再次填寫表單並提交。我爲主頁和第二頁創建了一個Web表單。當您在第二頁上提交表格時,它應該會在主頁(姓名,電子郵件,電話和選項選擇)上獲得詳細信息,然後我就可以開始工作了。但是,當我在Aweber帳戶的用戶上查看它時,第二頁中的字段全部爲空。首頁上的字段已完成,每當我完成填寫第二頁上的表單並提交時,Aweber說該頁面已被阻止。

他們建議我會爲此創建一個應用程序。但是我不知道如何開始,因爲他們的文檔令人驚歎。

我真的很感激,如果你能幫助我。

謝謝!

回答

13

它聽起來像你需要爲該功能創建一個aweber應用程序。

我正在粘貼幫助我快速安裝的PHP代碼。將其加載到瀏覽器中並按照指示進行操作。 準備好進行實際API調用後,您可以在labs.aweber.com/snippets/subscribers上看到一些示例。

如果遇到任何問題,您可以通過電子郵件[email protected]向aweber API支持發送電子郵件。

一對夫婦的你需要做的(如果你還沒有的話)的東西:

  1. 創建實驗室帳戶(http://labs.aweber.com)和aweber帳戶 (http://www.aweber.com
  2. 創建一個應用程序來獲得您的使用者密鑰和機密的實驗室現場
  3. 從實驗室站點下載AWeber PHP庫,並確保你有它正確的路徑在下面
放在require_once()
<?php 
require_once('aweber_api/aweber_api.php'); 
// Step 1: assign these values from https://labs.aweber.com/apps 
$consumerKey = ''; 
$consumerSecret = ''; 

// Step 2: load this PHP file in a web browser, and follow the instructions to set 
// the following variables: 
$accessKey = ''; 
$accessSecret = ''; 
$list_id = ''; 

if (!$consumerKey || !$consumerSecret){ 
    print "You need to assign \$consumerKey and \$consumerSecret at the top of this script and reload.<br><br>" . 
     "These are listed on <a href='https://labs.aweber.com/apps' target=_blank>https://labs.aweber.com/apps</a><br>\n"; 
    exit; 
} 

$aweber = new AWeberAPI($consumerKey, $consumerSecret); 
if (!$accessKey || !$accessSecret){ 
    display_access_tokens($aweber); 
} 

try { 
    $account = $aweber->getAccount($accessKey, $accessSecret); 
    $account_id = $account->id; 

    if (!$list_id){ 
     display_available_lists($account); 
     exit; 
    } 

    print "You script is configured properly! " . 
     "You can now start to develop your API calls, see the example in this script.<br><br>" . 
     "Be sure to set \$test_email if you are going to use the example<p>"; 

    //example: create a subscriber 
    /* 
    $test_email = ''; 
    if (!$test_email){ 
    print "Assign a valid email address to \$test_email and retry"; 
    exit; 
    } 
    $listURL = "/accounts/{$account_id}/lists/{$list_id}"; 
    $list = $account->loadFromUrl($listURL); 
    $params = array( 
     'email' => $test_email, 
     'ip_address' => '127.0.0.1', 
     'ad_tracking' => 'client_lib_example', 
     'misc_notes' => 'my cool app', 
     'name' => 'John Doe' 
    ); 
    $subscribers = $list->subscribers; 
    $new_subscriber = $subscribers->create($params); 
    print "{$test_email} was added to the {$list->name} list!"; 
    */ 

} catch(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>"; 
    exit(1); 
} 

function get_self(){ 
    return 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
} 

function display_available_lists($account){ 
    print "Please add one for the lines of PHP Code below to the top of your script for the proper list<br>" . 
      "then click <a href='" . get_self() . "'>here</a> to continue<p>"; 

    $listURL ="/accounts/{$account->id}/lists/"; 
    $lists = $account->loadFromUrl($listURL); 
    foreach($lists->data['entries'] as $list){ 
     print "<pre>\$list_id = '{$list['id']}'; // list name:{$list['name']}\n</pre>"; 
    } 
} 

function display_access_tokens($aweber){ 
    if (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])){ 

     $aweber->user->requestToken = $_GET['oauth_token']; 
     $aweber->user->verifier = $_GET['oauth_verifier']; 
     $aweber->user->tokenSecret = $_COOKIE['secret']; 

     list($accessTokenKey, $accessTokenSecret) = $aweber->getAccessToken(); 

     print "Please add these lines of code to the top of your script:<br>" . 
       "<pre>" . 
       "\$accessKey = '{$accessTokenKey}';\n" . 
       "\$accessSecret = '{$accessTokenSecret}';\n" . 
       "</pre>" . "<br><br>" . 
       "Then click <a href='" . get_self() . "'>here</a> to continue"; 
     exit; 
    } 

    if(!isset($_SERVER['HTTP_USER_AGENT'])){ 
     print "This request must be made from a web browser\n"; 
     exit; 
    } 

    $callbackURL = get_self(); 
    list($key, $secret) = $aweber->getRequestToken($callbackURL); 
    $authorizationURL = $aweber->getAuthorizeUrl(); 

    setcookie('secret', $secret); 

    header("Location: $authorizationURL"); 
    exit(); 
} 
?> 
+0

謝謝!真的很感激它。 – 2013-03-15 07:37:03

+0

男人,如果我可以投這個答案上百倍,這是不夠的!謝謝你,先生。 – 2013-06-04 22:25:25

+0

非常感謝你爲這段代碼片斷。 Aweber API文檔是有史以來最糟糕的。 – Vincent 2013-12-16 02:41:06