我可以直接通過URL訪問這個腳本,它可以正常工作,但作爲cron作業不起作用。它是偉大的還是我做錯了什麼?Aweber不允許cron作業
Awebre的文檔是我遇到過的最糟糕的文檔之一!
我不確定爲什麼在他們的文檔中沒有這個解釋!
感謝
<?php
include "wp-load.php";
include_once('wp-includes/class-phpass.php');
$sql = "SELECT member_id, email FROM wp_members_tbl WHERE aweber != 1";
$result = $wpdb->get_results($sql);
if(count($result)>0)
\t {
\t \t ##Add aweber
\t \t require_once('aweber/aweber_api/aweber_api.php');
\t \t $consumerKey = '***';
\t \t $consumerSecret = '***';
\t \t $accessKey = '***'; # put your credentials here
\t \t $accessSecret = '***'; # put your credentials here
\t \t $account_id = '***'; # put the Account ID here
\t \t $list_id = '***'; # put the List ID here 3823593
\t \t $aweber = new AWeberAPI($consumerKey, $consumerSecret);
\t \t # Get an access token
\t \t if(empty($_COOKIE['accessToken']))
\t \t {
\t \t if (empty($_GET['oauth_token']))
\t \t {
\t \t $callbackUrl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
\t \t list($requestToken, $requestTokenSecret) = $aweber->getRequestToken($callbackUrl);
\t \t setcookie('requestTokenSecret', $requestTokenSecret);
\t \t setcookie('callbackUrl', $callbackUrl);
\t \t header("Location: {$aweber->getAuthorizeUrl()}");
\t \t exit();
\t \t }
\t \t $aweber->user->tokenSecret = $_COOKIE['requestTokenSecret'];
\t \t $aweber->user->requestToken = $_GET['oauth_token'];
\t \t $aweber->user->verifier = $_GET['oauth_verifier'];
\t \t list($accessToken, $accessTokenSecret) = $aweber->getAccessToken();
\t \t setcookie('accessToken', $accessToken);
\t \t setcookie('accessTokenSecret', $accessTokenSecret);
\t \t header('Location: '.$_COOKIE['callbackUrl']);
\t \t exit();
\t \t \t }
\t \t ##End add aweber
\t \t foreach($result as $val=>$row)
\t \t \t {
\t \t \t \t # Get AWeber Account
\t \t \t \t \t try {
\t \t \t \t \t $account = $aweber->getAccount($_COOKIE['accessToken'], $_COOKIE['accessTokenSecret']);
\t \t \t \t \t $listURL = "https://api.aweber.com/1.0/accounts/***/lists/".$list_id;
\t \t \t \t \t $list = $account->loadFromUrl($listURL);
\t \t \t \t \t \t \t $params = array(
\t \t \t \t \t 'email' => $row->email
\t \t \t \t \t );
\t \t \t \t \t $subscribers = $list->subscribers;
\t \t \t \t \t $new_subscriber = $subscribers->create($params);
\t \t \t \t \t \t \t $update_data = array('aweber' => 1);
\t \t \t \t \t \t \t $where = array('member_id' => $row->member_id);
\t \t \t \t \t \t \t $wpdb->update('wp_members_tbl', $update_data, $where, $format = null, $where_format = null);
\t \t \t \t \t
\t \t \t \t \t \t \t \t \t \t # success!
\t \t \t \t \t //print "A new subscriber was added to the $list->name list!";
\t \t \t \t \t }
\t \t \t \t \t catch(AWeberAPIException $exc)
\t \t \t \t \t {
\t \t \t \t \t print "<h3>AWeberAPIException:</h3>";
\t \t \t \t \t print " <li> Type: $exc->type <br>";
\t \t \t \t \t print " <li> Msg : $exc->message <br>";
\t \t \t \t \t print " <li> Docs: $exc->documentation_url <br>";
\t \t \t \t \t print "<hr>";
\t \t \t \t \t //exit(1);
\t \t \t \t \t }
\t \t \t }
\t }