如何防止aweber在没有点击事件的情况下显示登录页面

时间:2018-03-19 09:57:56

标签: javascript php api codeigniter aweber

我正在使用codeignitor并进行整合。所有工作正常,我不想看到网页的登录页面而不点击按钮。

我从这里下载https://github.com/aweber/AWeber-API-PHP-Library只需更改消费者密钥和consumersecret



<a title="New account" href='<?php echo base_url ('/index.php/Welcome'); ?>' onclick>New account</a>


<?php
require_once('aweber_api/aweber_api.php');
// Replace with the keys of your application
// NEVER SHARE OR DISTRIBUTE YOUR APPLICATIONS'S KEYS!
$consumerKey    = "nnnnn";
$consumerSecret = "ddddddd";

$aweber = new AWeberAPI($consumerKey, $consumerSecret);

if (empty($_COOKIE['accessToken'])) 
{
    if (empty($_GET['oauth_token'])) {
        $callbackUrl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
        list($requestToken, $requestTokenSecret) = $aweber->getRequestToken($callbackUrl);
        setcookie('requestTokenSecret', $requestTokenSecret);
        setcookie('callbackUrl', $callbackUrl);
        header("Location: {$aweber->getAuthorizeUrl()}");
        exit();
    }

    $aweber->user->tokenSecret = $_COOKIE['requestTokenSecret'];
    $aweber->user->requestToken = $_GET['oauth_token'];
    $aweber->user->verifier = $_GET['oauth_verifier'];
    list($accessToken, $accessTokenSecret) = $aweber->getAccessToken();
    setcookie('accessToken', $accessToken);
    setcookie('accessTokenSecret', $accessTokenSecret);
    header('Location: '.$_COOKIE['callbackUrl']);
    exit();
}

# set this to true to view the actual api request and response
$aweber->adapter->debug = false;

$account = $aweber->getAccount($_COOKIE['accessToken'], $_COOKIE['accessTokenSecret']);

?>
<!DOCTYPE html>
<html lang="en">
<head>
  <title>AWeber Test Application</title>
  <link type="text/css" rel="stylesheet" href="styles.css" />
<body style="display: none;">
<?php
foreach($account->lists as $offset => $list) {
?>
<h1>List: <?php echo $list->name; ?></h1>
<h3><?php echo $list->id; ?></h3>
<table>
  <tr>
    <th class="stat">Subject</th>
    <th class="value">Sent</th>
    <th class="value">Stats</th>
  </tr>
<?php
foreach($list->campaigns as $campaign) {
    if ($campaign->type == 'broadcast_campaign') {
?>
    <tr>
        <td class="stat"><em><?php echo $campaign->subject; ?></em></td>
        <td class="value"><?php echo date('F j, Y h:iA', strtotime($campaign->sent_at)); ?></td>
        <td class="value"><ul>
              <li><b>Opened:</b>  <?php echo $campaign->total_opens; ?></li>
              <li><b>Sent:</b>  <?php echo $campaign->total_sent; ?></li>
              <li><b>Clicked:</b>  <?php echo $campaign->total_clicks; ?></li>
            </ul>
        </td>
    <?php
    }
} ?>
</table>
<?php }
?>
<body>
</html>
&#13;
&#13;
&#13;

单击此按钮后,我希望所有数据都在同一页面上

<a title="New account" href='<?php echo base_url ('/index.php/Welcome'); ?>' onclick>New account</a>

1 个答案:

答案 0 :(得分:0)

从AWeber获得请求令牌后,您可以使用一个转到此URL的按钮:

https://auth.aweber.com/1.0/oauth/authorize?oauth_token={your_request_token}

当你的onClick运行时,这将打开AWeber登录。您可以将回调URL设置为获取请求令牌时的任何内容,因此在用户登录后,他们将被重定向到下一页,您可以从我们的响应中处理验证者令牌。这在这里描述:

https://labs.aweber.com/docs/authentication