1

URL 経由でこのスクリプトに直接アクセスできます。問題なく動作しますが、cron ジョブとしては機能しません。それはaweberですか、それとも何か間違ったことをしていますか?

Awebre のドキュメントは、私が今まで出会った中で最悪のものの 1 つです。

彼らのドキュメントにこれについての説明がない理由がわかりません!

ありがとう

<?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)
	{
		##Add aweber
		require_once('aweber/aweber_api/aweber_api.php');
		$consumerKey = '***';
		$consumerSecret = '***';
		$accessKey      = '***'; # put your credentials here
		$accessSecret   = '***'; # put your credentials here
		$account_id     = '***'; # put the Account ID here
		$list_id        = '***'; # put the List ID here 3823593   
		$aweber = new AWeberAPI($consumerKey, $consumerSecret);
		# Get an access token
		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();
			}
		##End add aweber

		foreach($result as $val=>$row)
			{
				# Get AWeber Account
					try {
					        $account = $aweber->getAccount($_COOKIE['accessToken'], $_COOKIE['accessTokenSecret']);
					        $listURL = "https://api.aweber.com/1.0/accounts/***/lists/".$list_id;
					        $list = $account->loadFromUrl($listURL);
							$params = array(
					            'email' => $row->email
					        );
					        $subscribers = $list->subscribers;
					        $new_subscriber = $subscribers->create($params);
							$update_data = array('aweber' => 1);
							$where = array('member_id' => $row->member_id);
							$wpdb->update( 'wp_members_tbl', $update_data, $where, $format = null, $where_format = null);
					        
					       					        # success!
					        //print "A new subscriber 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);
					    }
			}
	}

4

2 に答える 2

0

cron コマンドでこれを使用してみてください。

wget -qO- http://yoururlhere/ &> /dev/null

「自己呼び出し」は推奨されないため、これは最善の解決策ではありませんが、環境設定を処理できなくなります。

于 2015-09-08T07:22:30.787 に答える