如何在 Aweber 中创建应用程序? [英] How to create an app in Aweber?

查看:26
本文介绍了如何在 Aweber 中创建应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 https://labs.aweber.com/apps 上创建了一个应用程序并下载了 php他们 github 上的代码 https://github.com/aweber/AWeber-API-PHP-Library.我读过他们的文档,但不是很清楚.我不知道如何开始或先做什么.我只是一个初学者,我以前从未制作过应用程序.

我首先尝试在我的页面上创建 PHP 脚本,希望在提交表单时满足所需的功能,但没有任何反应.我联系了他们的支持,但他们建议制作一个应用程序以使其正常工作.

Web 表单提交的流程是这样的.在主页中,用户将输入其姓名、电子邮件、电话,并且有两个单选选项可供选择,当您选择一个时,它会重定向到另一个页面并再次填写表单并提交.我为主页和第二页创建了一个网络表单.当您在第二页上提交表单时,它应该会在主页上获得详细信息(姓名、电子邮件、电话和选项选择),然后我就成功了.但是当我在我的 Aweber 帐户的订阅者上查看它时,第二页中的字段都是空白的.主页上的字段已完成,每当我填写完第二页上的表单并提交时,Aweber 都会说该页面已被阻止.

他们建议我为此创建一个应用程序.但我不知道如何开始,因为他们的文档令人难以置信.

如果您能帮助我,我将不胜感激.

谢谢!

解决方案

听起来您确实需要为该功能创建一个 weber 应用程序.

我正在粘贴 PHP 代码,这有助于我快速完成设置.在浏览器中加载它并按照说明进行操作.准备好进行实际 API 调用后,您可以在 labs.aweber.com/snippets/subscribers 上查看一些示例.

如果您遇到任何问题,您可以随时通过 api@aweber.com 向 aweber API 支持发送电子邮件.

您需要做的几件事(如果您还没有):

  1. 创建实验室帐户 (http://labs.aweber.com) 和 aweber 帐户(http://www.aweber.com)
  2. 创建一个应用以在实验室站点获取您的消费者密钥和机密
  3. 从实验室站点下载 AWeber php 库,并确保在下面的 require_once() 中有正确的路径

<块引用>

//第 1 步:从 https://labs.aweber.com/apps 分配这些值$consumerKey = '';$consumerSecret = '';//第二步:在网页浏览器中加载这个PHP文件,并按照说明进行设置//以下变量:$accessKey = '';$accessSecret = '';$list_id = '';如果 (!$consumerKey || !$consumerSecret){print "您需要在此脚本的顶部分配 \$consumerKey 和 \$consumerSecret 并重新加载.<br><br>"."这些都列在 <a href='https://labs.aweber.com/apps' target=_blank>https://labs.aweber.com/apps</a><br>\n";出口;}$aweber = new AWeberAPI($consumerKey, $consumerSecret);如果 (!$accessKey || !$accessSecret){display_access_tokens($aweber);}尝试 {$account = $aweber->getAccount($accessKey, $accessSecret);$account_id = $account->id;如果(!$list_id){display_available_lists($account);出口;}打印您的脚本配置正确!".您现在可以开始开发 API 调用,请参阅此脚本中的示例.<br><br>"."如果您要使用示例

,请务必设置\$test_email";//示例:创建订阅者/*$test_email = '';如果(!$test_email){print "为 \$test_email 分配一个有效的电子邮件地址并重试";出口;}$listURL = "/accounts/{$account_id}/lists/{$list_id}";$list = $account->loadFromUrl($listURL);$params = 数组('电子邮件' =>$test_email,'ip_address' =>'127.0.0.1','ad_tracking' =>'client_lib_example','misc_notes' =>我的酷应用",'名称' =>《约翰·多伊》);$subscribers = $list->subscribers;$new_subscriber = $subscribers->create($params);print "{$test_email} 已添加到 {$list->name} 列表中!";*/} catch(AWeberAPIException $exc) {打印 "<h3>AWeberAPIException:</h3>";打印"<li>类型:$exc->类型<br>";打印 " <li> Msg : $exc->message <br>";打印 " <li> Docs: $exc->documentation_url <br>";打印<hr>";退出(1);}函数 get_self(){返回 '​​http://' .$_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI'];}函数 display_available_lists($account){打印请将下面的 PHP 代码行添加到脚本的顶部以获得正确的列表<br>"."然后点击 <a href='" .get_self() ."'>这里</a>继续<p>";$listURL ="/accounts/{$account->id}/lists/";$lists = $account->loadFromUrl($listURL);foreach($lists->data['entries'] 作为 $list ){print "<pre>\$list_id = '{$list['id']}';//列表名称:{$list['name']}\n</pre>";}}功能 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();打印请将这些代码行添加到脚本的顶部:<br>".<预>"."\$accessKey = '{$accessTokenKey}';\n" ."\$accessSecret = '{$accessTokenSecret}';\n" .</预>".<br><br>"."然后点击 <a href='" .get_self() ."'>这里</a>继续";出口;}if(!isset($_SERVER['HTTP_USER_AGENT'])){print "此请求必须从 Web 浏览器发出\n";出口;}$callbackURL = get_self();list($key, $secret) = $aweber->getRequestToken($callbackURL);$authorizationURL = $aweber->getAuthorizeUrl();setcookie('秘密', $secret);header("位置:$authorizationURL");出口();}?>

I create an app on https://labs.aweber.com/apps and download the php codes on their github https://github.com/aweber/AWeber-API-PHP-Library. Ive read their docs but its not that clearly. I dont know how to start or what to do first. Im just a beginner and I never made an app before.

I tried first creating PHP scripts on my pages hoping to meet a desired functionality when submitting a form but nothing happened. I contact their support but they suggest making an app to make it work correctly.

The flow of the web form submission was like this. In the homepage, a user would input its Name, Email, Phone and there are two radio options to choose, when you choose one, it would redirect to another page and fill out a form again and submit it. I created a web form for the homepage and also on the second page. When you submit the form on second page, it should get the details on the homepage (Name,Email,Phone and option choose) and I got it worked. But when I view it on the subscribers on my Aweber account, the fields in the second page is all blank. The fields on the homepage was complete and whenever I finish filling up the form on the second page and submit it, the Aweber says the page has been blocked.

They suggest I would create an app for that. But I don't know how to get started because their docs is mindboggling.

I would really appreciate if you could help me.

Thanks!

解决方案

It does sound like you need to create an aweber app for that functionality.

I'm pasting PHP code which has helped me get setup very quickly. Load it in your browser and follow the directions. Once you are ready to make actual API calls, you can see some examples at labs.aweber.com/snippets/subscribers.

If you run into any issues you can always email aweber API support at api@aweber.com.

A couple of things you need to do (if you haven't already):

  1. Create a labs account (http://labs.aweber.com) and an aweber account (http://www.aweber.com)
  2. Create an app to get your consumer key and secret at the labs site
  3. Download the AWeber php library from the labs site and make sure you have the proper path to it in the require_once() below

<?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();
}
?>

这篇关于如何在 Aweber 中创建应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆