Php 页面加载点击按钮
我尝试了很多东西,比如window.stop,但是不起作用,并且尝试在代码中创建一些函数,但是再次失败 这是我的钮扣Php 页面加载点击按钮,php,api,aweber,Php,Api,Aweber,我尝试了很多东西,比如window.stop,但是不起作用,并且尝试在代码中创建一些函数,但是再次失败 这是我的钮扣 <input type="button" value="Click Me"> <?php require_once('aweber_api/aweber_api.php'); // <!-- // Replace with the keys of your application // // NEVER SHARE OR DISTRIBUTE YOU
<input type="button" value="Click Me">
<?php
require_once('aweber_api/aweber_api.php');
// <!-- // Replace with the keys of your application
// // NEVER SHARE OR DISTRIBUTE YOUR APPLICATIONS'S KEYS! -->
$consumerKey = "aaaa";
$consumerSecret = "bbbbb";
$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>
<?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>
您没有检查按钮是否已单击以及页面加载时脚本是否正在运行。你也可以检查你的请求,只有当它是POST时,你才可以做一些事情。根据您的代码:
<form method="POST">
<input type="submit" name="myButton" value="Click Me">
</form>
<?php
// Check if the request is post
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Check if the button is clicked
if (isset($_POST['myButton'])) {
// Your code here
}
}
// Some other code here
?>
请用确切的问题更新您的问题。您的按钮在哪里?@SmitRaval请检查我刚刚添加的按钮。问题是当我加载此页面时,它会将我带到一个浏览器登录。但我想在点击按钮后继续。登录后,我想回到同一页面。谢谢您的回复。我试过你和我分享的东西。我的JSFIDLE按钮不工作。非常感谢你编辑了我的答案。最好将输入的类型改为submit而不是button,并将其放在表单元素中,以指定您想要POST请求。很高兴我帮了你。你是超级英雄。这是从两天开始的尝试。:)再次感谢