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

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

问题描述

我创建 https://labs.aweber.com/apps 一个应用程序,并下载PHP codeS他们github上 https://github.com/aweber/AWeber-API- PHP库。香港专业教育学院读他们的文档,但它不是明确。我不知道如何启动或先做什么。我只是个初学者,我以前从未开发的应用。

我第一次尝试在网页上创建的PHP脚本希望能满足所需的功能提交表单,但什么都没有发生的时候。我与他们的支持,但他们建议将某个应用,使其正常工作。

Web表单提交的流程是这样的。在主页,用户将输入其姓名,电子邮件,电话和有两个无线电选项可供选择,当你选择一个,它会重定向到另一个页面,再填写一张表格并提交。我创建了一个Web表单主页,并在第二页上。当您提交第二页上的形式,它应该得到主页上的详细信息(姓名,电子邮件,电话和可供选择),我得到它的工作。但是,当我认为它在我的Aweber帐户的用户,在第二页中的字段是均为空。在主页上的字段是完整的,每当我完成第二页上填写了表格并提交时,Aweber说,网页已被封锁。

他们建议我将创造一个应用程序。但我不知道如何开始,因为他们的文档是mindboggling。

我真的AP preciate如果你能帮助我。

谢谢!


解决方案

这听起来像你需要创建该功能的应用程序aweber

我粘贴PHP code这使我非常迅速得到建立。它加载到你的浏览器,并按照指示。
一旦你准备好进行实际的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()低于


 < PHP
require_once('aweber_api / aweber_api.php');


  //第1步:从https://labs.aweber.com/apps分配这些值
$ consumerKey ='';
$ consumerSecret ='';//第2步:加载一个网页浏览器的PHP文件,然后按照说明设置
//以下变量:
$ ACCESSKEY ='';
$ accessSecret ='';
$ LIST_ID ='';如果(!$ consumerKey ||!$ consumerSecret){
    打印你需要分配\\ $ consumerKey和\\ $ consumerSecret在这个脚本的顶部和重装< BR>< BR>中。
        这些都列针对&lt; A HREF =的https://labs.aweber.com/appsTARGET = _blank&GT;的https://labs.aweber.com/apps< / A&GT;&LT; BR&GT; \\ N的;
    出口;
}$ aweber =新AWeberAPI($ consumerKey,$ consumerSecret);
如果(!$ ACCESSKEY ||!$ accessSecret){
    display_access_tokens($ aweber);
}尝试{
    $帐户= $ aweber-&GT;是getAccount($ ACCESSKEY,$ accessSecret);
    $ ACCOUNT_ID = $问责&GT; ID;    如果(!$ LIST_ID){
        display_available_lists($帐户);
        出口;
    }    打印你的脚本配置是否正确!。
        你现在可以开始开发你的API调用,看到这个剧本的例子&LT; BR&GT;&LT; BR&gt;中。
        一定要设置\\ $ test_email如果你打算使用的例子&LT; P&gt;中;    //例如:建立一个用户
    / *
    $ test_email ='';
    如果(!$ test_email){
    打印指定一个有效的电子邮件地址\\ $ test_email,然后重试;
    出口;
    }
    $ listURL =/帐号/ {$ ACCOUNT_ID} /列表/ {$ LIST_ID};
    $名单= $问责&GT; loadFromUrl($ listURL);
    $ PARAMS =阵列(
        电子邮件=&GT; $ test_email,
        'IP_ADDRESS'=&GT; 127.0.0.1,
        ad_tracking'=&GT; client_lib_example',
        misc_notes'=&GT; 我的酷应用程序,
        '名'=&GT; 李四
    );
    $用户= $列表 - &GT;用户;
    $ new_subscriber = $ subscribers-&GT;创建($ params)方法;
    打印{$ test_email}加入到{$列表 - &GT;名}!名单;
    * /}赶上(AWeberAPIException $ EXC){
    打印&所述; H3&GT; AWeberAPIException:或其可/ H3&gt;中;
    打印&LT;立GT;类型:$ EXC-&GT;类型&lt; BR&gt;中;
    打印&LT;立GT;消息:$ EXC-&gt;消息&LT; BR&gt;中;
    打印&LT;立GT;文件:$ EXC-&GT; documentation_url&LT; BR&gt;中;
    打印&LT;小时&gt;中;
    出口(1);
}功能get_self(){
    回归的http://。 $ _ SERVER ['HTTP_HOST']。 $ _ SERVER ['REQUEST_URI'];
}功能display_available_lists($帐户){
    打印请新增一个PHP的code以下到脚本的正确列表&LT顶部的线条; BR&gt;中。
            ,然后单击&lt; A HREF ='。 get_self()。 '&gt;此处&下; / A&gt;到继续&所述; P&gt;中;    $ listURL =/帐号/ {$问责&GT; ID} /列表/;
    $名单= $问责&GT; loadFromUrl($ listURL);
    的foreach($ lists-&GT;数据['项']为$名单){
        打印&LT; pre&GT; \\ $ LIST_ID ='{$表['身份证']}'; //列表名称:{$列表[名称]} \\ n&LT; / pre&gt;中;
    }
}功能display_access_tokens($ aweber){
    如果(使用isset($ _ GET ['组oauth_token'])及和放大器;使用isset($ _ GET ['oauth_verifier'])){        $ aweber-&GT;用户自&GT; requestToken = $ _GET ['组oauth_token'];
        $ aweber-&GT;用户自&GT;验证= $ _GET ['oauth_verifier'];
        $ aweber-&GT;用户自&GT; tokenSecret = $ _COOKIE ['秘密'];        列表($ accessTokenKey,$ accessTokenSecret)= $ aweber-&GT; getAccessToken();        打印请code的这些行添加到您的脚本的顶部:其中; BR&gt;中。
                &LT; pre&gt;中。
                \\ $ ACCESSKEY ='{$ accessTokenKey}'; \\ N。
                \\ $ accessSecret ='{$ accessTokenSecret}'; \\ N。
                &LT; / pre&gt;中。 &LT; BR&GT;&LT; BR&gt;中。
                然后单击&lt; A HREF ='。 get_self()。 '&gt;此处&下; / A&gt;至继续;
        出口;
    }    如果(!使用isset($ _ SERVER ['HTTP_USER_AGENT'])){
        打印这个请求必须从Web浏览器\\ n取得;
        出口;
    }    $ callbackURL = get_self();
    列表($键,$密码)= $ aweber-&GT; getRequestToken($ callbackURL);
    $ authorizationURL = $ aweber-&GT; getAuthorizeUrl();    的setcookie('秘密',$密码);    标题(位置:$ authorizationURL);
    出口();
}
?&GT;

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天全站免登陆